diff --git a/public/algorithms/mix-tree.js b/public/algorithms/mix-tree.js index 5f0e671..89ed534 100644 --- a/public/algorithms/mix-tree.js +++ b/public/algorithms/mix-tree.js @@ -11,6 +11,7 @@ * @property {number} maxTreeDepth * @property {Array} 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 diff --git a/src/components/Node/Leaf.jsx b/src/components/Node/Leaf.jsx index 225c3c9..21f6026 100644 --- a/src/components/Node/Leaf.jsx +++ b/src/components/Node/Leaf.jsx @@ -62,43 +62,76 @@ function Leaf({ category, matchedCount, notMatchedCount, quality, requestLeafUnf flexWrap="wrap-reverse" alignItems="flex-end" > - + {isNotModify ? (
) : ( - - {/* */} - } - //bg={'#009c72'} - // _hover={{ - // bg: '#00402f', - // }} - // _active={{ - // bg: '#00402f', - // }} - bg={'#1560ab'} - _hover={{ - bg: '#005069', - }} - _active={{ - bg: '#005069', - }} - color={'white'} - > - Unfold all - - {/* */} - - requestLeafUnfold(['c45'])}>C 4.5 - requestLeafUnfold(['tsp'])}>TSP - requestLeafUnfold(['tspw'])}>TSP Weight - - + + + } + bg={'#1560ab'} + _hover={{ + bg: '#005069', + }} + _active={{ + bg: '#005069', + }} + color={'white'} + marginBottom={1} + textAlign={'left'} + paddingLeft={'13px'} + > + Unfold once + + {/* */} + + requestLeafUnfold(['c45'], true)}>C 4.5 + requestLeafUnfold(['tsp'], true)}>TSP + requestLeafUnfold(['tspw'], true)}>TSP Weight + + + + {/* */} + } + 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 + + {/* */} + + requestLeafUnfold(['c45'])}>C 4.5 + requestLeafUnfold(['tsp'])}>TSP + requestLeafUnfold(['tspw'])}>TSP Weight + + + )}
diff --git a/src/components/Node/index.jsx b/src/components/Node/index.jsx index 7ea0a73..1b84ab7 100644 --- a/src/components/Node/index.jsx +++ b/src/components/Node/index.jsx @@ -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); diff --git a/src/utils/algorithm-executor.js b/src/utils/algorithm-executor.js index 270db8b..a0bc216 100644 --- a/src/utils/algorithm-executor.js +++ b/src/utils/algorithm-executor.js @@ -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);