mirror of
https://github.com/hsokolowski/iTree.git
synced 2026-06-10 22:04:16 -04:00
add unfold once
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
* @property {number} maxTreeDepth
|
||||
* @property {Array<string>} ignoredAttributes
|
||||
* @property {string} algorithm
|
||||
* @property {boolean} unfoldOnce
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -28,6 +29,8 @@ function buildDecisionTreeMix(_builder) {
|
||||
maxTreeDepth,
|
||||
ignoredAttributes,
|
||||
algorithm,
|
||||
unfoldOnce = false,
|
||||
runOnce = false,
|
||||
allClasses,
|
||||
} = builder;
|
||||
|
||||
@@ -123,7 +126,7 @@ function buildDecisionTreeMix(_builder) {
|
||||
}
|
||||
|
||||
//LEAF
|
||||
if (match.length === 0 || notMatch.length === 0) {
|
||||
if (match.length === 0 || notMatch.length === 0 || runOnce) {
|
||||
//console.log('Liść bo Lewa/Prawa wynosi 0');
|
||||
let _category = mostFrequentValue(trainingSet, categoryAttr);
|
||||
let _positiveCounter = 0;
|
||||
@@ -143,6 +146,12 @@ function buildDecisionTreeMix(_builder) {
|
||||
};
|
||||
}
|
||||
|
||||
if (unfoldOnce) {
|
||||
console.log(unfoldOnce, unfoldOnce === false);
|
||||
console.log('Match/NotMatch');
|
||||
builder.runOnce = true;
|
||||
}
|
||||
|
||||
builder.maxTreeDepth = maxTreeDepth - 1;
|
||||
builder.trainingSet = match;
|
||||
var matchSubTree = buildDecisionTreeMix(builder); //savesubtreesinfothreshold
|
||||
|
||||
@@ -62,43 +62,76 @@ function Leaf({ category, matchedCount, notMatchedCount, quality, requestLeafUnf
|
||||
flexWrap="wrap-reverse"
|
||||
alignItems="flex-end"
|
||||
>
|
||||
<Box boxShadow="md">
|
||||
<Box>
|
||||
{isNotModify ? (
|
||||
<div></div>
|
||||
) : (
|
||||
<Menu closeOnSelect closeOnBlur isLazy>
|
||||
{/* <Tooltip hasArrow label="Unfold to node" bg="yellow.500" placement="right"> */}
|
||||
<MenuButton
|
||||
fontSize="sm"
|
||||
w={100}
|
||||
h={6}
|
||||
as={Button}
|
||||
rightIcon={<ChevronDownIcon />}
|
||||
//bg={'#009c72'}
|
||||
// _hover={{
|
||||
// bg: '#00402f',
|
||||
// }}
|
||||
// _active={{
|
||||
// bg: '#00402f',
|
||||
// }}
|
||||
bg={'#1560ab'}
|
||||
_hover={{
|
||||
bg: '#005069',
|
||||
}}
|
||||
_active={{
|
||||
bg: '#005069',
|
||||
}}
|
||||
color={'white'}
|
||||
>
|
||||
Unfold all
|
||||
</MenuButton>
|
||||
{/* </Tooltip> */}
|
||||
<MenuList>
|
||||
<MenuItem onClick={() => requestLeafUnfold(['c45'])}>C 4.5</MenuItem>
|
||||
<MenuItem onClick={() => requestLeafUnfold(['tsp'])}>TSP</MenuItem>
|
||||
<MenuItem onClick={() => requestLeafUnfold(['tspw'])}>TSP Weight</MenuItem>
|
||||
</MenuList>
|
||||
</Menu>
|
||||
<Box display={'flex'} flexDirection={'column'}>
|
||||
<Menu closeOnSelect closeOnBlur isLazy>
|
||||
<MenuButton
|
||||
fontSize="sm"
|
||||
w={110}
|
||||
h={6}
|
||||
as={Button}
|
||||
rightIcon={<ChevronDownIcon />}
|
||||
bg={'#1560ab'}
|
||||
_hover={{
|
||||
bg: '#005069',
|
||||
}}
|
||||
_active={{
|
||||
bg: '#005069',
|
||||
}}
|
||||
color={'white'}
|
||||
marginBottom={1}
|
||||
textAlign={'left'}
|
||||
paddingLeft={'13px'}
|
||||
>
|
||||
Unfold once
|
||||
</MenuButton>
|
||||
{/* </Tooltip> */}
|
||||
<MenuList>
|
||||
<MenuItem onClick={() => requestLeafUnfold(['c45'], true)}>C 4.5</MenuItem>
|
||||
<MenuItem onClick={() => requestLeafUnfold(['tsp'], true)}>TSP</MenuItem>
|
||||
<MenuItem onClick={() => requestLeafUnfold(['tspw'], true)}>TSP Weight</MenuItem>
|
||||
</MenuList>
|
||||
</Menu>
|
||||
<Menu closeOnSelect closeOnBlur isLazy>
|
||||
{/* <Tooltip hasArrow label="Unfold to node" bg="yellow.500" placement="right"> */}
|
||||
<MenuButton
|
||||
fontSize="sm"
|
||||
w={110}
|
||||
h={6}
|
||||
as={Button}
|
||||
rightIcon={<ChevronDownIcon />}
|
||||
paddingLeft={1}
|
||||
paddingRight={1}
|
||||
textAlign={'left'}
|
||||
//bg={'#009c72'}
|
||||
// _hover={{
|
||||
// bg: '#00402f',
|
||||
// }}
|
||||
// _active={{
|
||||
// bg: '#00402f',
|
||||
// }}
|
||||
bg={'#1560ab'}
|
||||
_hover={{
|
||||
bg: '#005069',
|
||||
}}
|
||||
_active={{
|
||||
bg: '#005069',
|
||||
}}
|
||||
color={'white'}
|
||||
>
|
||||
Unfold all
|
||||
</MenuButton>
|
||||
{/* </Tooltip> */}
|
||||
<MenuList>
|
||||
<MenuItem onClick={() => requestLeafUnfold(['c45'])}>C 4.5</MenuItem>
|
||||
<MenuItem onClick={() => requestLeafUnfold(['tsp'])}>TSP</MenuItem>
|
||||
<MenuItem onClick={() => requestLeafUnfold(['tspw'])}>TSP Weight</MenuItem>
|
||||
</MenuList>
|
||||
</Menu>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
<Box fontWeight="700" fontSize={30}>
|
||||
|
||||
@@ -108,12 +108,13 @@ const Node = props => {
|
||||
props.requestChildChange(foldResult);
|
||||
};
|
||||
|
||||
const unfoldLeaf = algorithm => {
|
||||
const unfoldLeaf = (algorithm, unfoldOnce = false) => {
|
||||
setLoading(true);
|
||||
executeAlgorithm({
|
||||
...builderConfig,
|
||||
trainingSet: node.trainingSet2,
|
||||
algorithm,
|
||||
unfoldOnce,
|
||||
})
|
||||
.then(value => {
|
||||
setNode(value);
|
||||
|
||||
@@ -9,14 +9,14 @@ const workersMap = {
|
||||
export function executeAlgorithm(options, changeOptions = {}) {
|
||||
//console.log(changeOptions);
|
||||
return new Promise((resolve, reject) => {
|
||||
//console.time(options.algorithm);
|
||||
let worker;
|
||||
if (options.algorithm.length > 1) {
|
||||
console.log('mix');
|
||||
worker = new Worker(`algorithms/${workersMap.mix}-tree.js`);
|
||||
} else {
|
||||
worker = new Worker(`algorithms/${workersMap[options.algorithm[0]]}-tree.js`);
|
||||
}
|
||||
console.time('options.unfold.Once', options.unfoldOnce);
|
||||
let worker = new Worker(`algorithms/${workersMap.mix}-tree.js`);
|
||||
// if (options.algorithm.length > 1) {
|
||||
// console.log('mix');
|
||||
// worker = new Worker(`algorithms/${workersMap.mix}-tree.js`);
|
||||
// } else {
|
||||
// worker = new Worker(`algorithms/${workersMap[options.algorithm[0]]}-tree.js`);
|
||||
// }
|
||||
worker.onmessage = ({ data }) => {
|
||||
console.log('got a result', data);
|
||||
resolve(data);
|
||||
|
||||
Reference in New Issue
Block a user