From 121a02ad68cd932ed24ef6e3828a64db98fb383e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20Soko=C5=82owski?= Date: Sun, 14 Aug 2022 16:13:14 +0200 Subject: [PATCH] without login --- src/App.jsx | 6 +-- .../Crossvalidator/Crossvalidator.jsx | 42 +++++++++++++------ src/components/Crossvalidator/sampleTree.scss | 4 +- src/components/Main.jsx | 2 +- src/components/ModelBuilder.jsx | 2 +- 5 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 39f32cb..4590bdc 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -15,9 +15,9 @@ function App() {
- -
-
+
+ {/* + */}
diff --git a/src/components/Crossvalidator/Crossvalidator.jsx b/src/components/Crossvalidator/Crossvalidator.jsx index f77cd63..2b5bc14 100644 --- a/src/components/Crossvalidator/Crossvalidator.jsx +++ b/src/components/Crossvalidator/Crossvalidator.jsx @@ -26,7 +26,7 @@ import TreePrinter from '../TreePrinter'; * @returns */ function CrossValidator({ builder, chunks, treeModels }) { - const [allAccuracy, setAllAccuracy] = useState({}); + const [allAccuracy, setAllAccuracy] = useState([]); const AllAccuracyObject = useMemo(() => Object.values(allAccuracy), [allAccuracy]); const [selectedTree, setSelectedTree] = useState(null); @@ -34,10 +34,16 @@ function CrossValidator({ builder, chunks, treeModels }) { const [acc, setAcc] = useState({}); function updateAccuracy(e, i) { + console.log('Accuracy'); + console.log(e, i); + if (allAccuracy.length != chunks.length) { + //setAllAccuracy([...allAccuracy, e]); + } // setAllAccuracy(prevState => ({ // ...prevState, // [i]: e, // })); + console.log(allAccuracy); } // useEffect(() => { @@ -87,14 +93,19 @@ function CrossValidator({ builder, chunks, treeModels }) { chunks={chunks} item={x} index={i} - onGetResults={e => updateAccuracy(e, i)} + onGetResults={updateAccuracy} onSelectedTree={selectTree} /> ))}
-

Training accuracy:{}

-

Test accuracy:

+

+ Training accuracy:{' '} + {allAccuracy?.reduce((partialSum, a) => partialSum + a.training, 0) / allAccuracy.length} +

+

+ Test accuracy: {allAccuracy?.reduce((partialSum, a) => partialSum + a.test, 0) / allAccuracy.length} +

Tree {selectedIndex + 1}

@@ -137,8 +148,12 @@ function CrossValidator({ builder, chunks, treeModels }) { export default CrossValidator; function SampleTreeItem({ builder, chunks, item, index, onGetResults, onSelectedTree }) { - const [trainAcc, setTrainAcc] = useState(0); - const [testAcc, setTestAcc] = useState(0); + const [trainAcc, setTrainAcc] = useState(null); + const [testAcc, setTestAcc] = useState(null); + const [acc, setAcc] = useState({ + training: null, + test: null, + }); function clickSelectTree(tree, index) { onSelectedTree(tree, index); @@ -146,18 +161,20 @@ function SampleTreeItem({ builder, chunks, item, index, onGetResults, onSelected function getTreningAccuracy(value) { setTrainAcc(value); + //onGetResults({ ...acc, training: value }); } function getTestAccuracy(value) { setTestAcc(value); + //onGetResults({ ...acc, test: value }); } useEffect(() => { - onGetResults({ - training: trainAcc, - test: testAcc, - }); - }, [onGetResults, testAcc, trainAcc]); + // console.log('usseeffececct', acc); + // if (acc.training != null && acc.test != null) { + // onGetResults(acc); + // } + }, [acc, onGetResults]); return ( -

clickSelectTree(item, index)}> +

clickSelectTree(item, index)}> Tree {index + 1}

diff --git a/src/components/Crossvalidator/sampleTree.scss b/src/components/Crossvalidator/sampleTree.scss index 671b5f3..3842996 100644 --- a/src/components/Crossvalidator/sampleTree.scss +++ b/src/components/Crossvalidator/sampleTree.scss @@ -1,7 +1,7 @@ .sampleTreeItem { &:hover { - border: 3px solid #3182ce; + //border: 1px solid #3182ce; cursor: pointer; - //background-color: #abcceb; + background-color: #abcceb; } } diff --git a/src/components/Main.jsx b/src/components/Main.jsx index 0ae3e88..8c0bba3 100644 --- a/src/components/Main.jsx +++ b/src/components/Main.jsx @@ -47,7 +47,7 @@ function Main() { {isReady ? ( folds != 0 ? (
- ModelBuidler + {/* ModelBuidler */}
) : ( diff --git a/src/components/ModelBuilder.jsx b/src/components/ModelBuilder.jsx index 3d032a8..ad1085f 100644 --- a/src/components/ModelBuilder.jsx +++ b/src/components/ModelBuilder.jsx @@ -63,7 +63,7 @@ function ModelBuilder({ builder, headers, fold }) { ...prevState, [i]: value, })); - + console.log('Set next step'); prog += step; setProgress(prog); })