Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3.2 single axis [DO NOT MERGE] #524

Open
wants to merge 127 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
a3e647f
Setup test for data representation
r59q May 1, 2024
71c9880
Fixed livegraph
r59q May 1, 2024
1ad7226
Merge branch 'issue-444' into 469-generalise-the-data-representation
r59q May 1, 2024
9c8a494
Make Stores container
r59q May 8, 2024
c1de2e5
Fix synthesizer
r59q May 8, 2024
5702eb7
Rename file
r59q May 8, 2024
fc109ff
Renamed file
r59q May 8, 2024
2ac5ca9
Improve state of logging and fix reconnect issue
r59q May 9, 2024
0059b99
Remove unused import
r59q May 9, 2024
47e39b8
Docker compose
r59q May 9, 2024
16c528c
Clarified import
r59q May 10, 2024
c40354b
Add whitespace
r59q May 10, 2024
eafb18d
Whitespace
r59q May 10, 2024
c5c196c
Whitespace
r59q May 10, 2024
fb8b4b7
Fix classifier test
r59q May 10, 2024
d4df57a
whitespace
r59q May 10, 2024
d80f1a0
Added test message
r59q May 10, 2024
ac49475
Removed test message
r59q May 10, 2024
15a8122
Enable development message in prod
r59q May 10, 2024
dee0fff
Reverted logging
r59q May 10, 2024
8bba125
Whitespace
r59q May 10, 2024
418c79a
Add workflow for deployment site
r59q May 10, 2024
3c56b76
Improve consistency for microbits object
r59q May 10, 2024
aa8c9db
Using key on LiveGraph
r59q May 13, 2024
36ea389
Remove Highlighted LiveGraph component
r59q May 13, 2024
de2b61b
Fix flickering confidences
r59q May 13, 2024
0599d6e
Fix issue where switching models would cause memory leaks
r59q May 14, 2024
6f880fe
Maybe fixed issue where axes couldn't be selected
r59q May 14, 2024
3924988
Remove log line
r59q May 14, 2024
1dc8bc1
Stabilize switching between models
r59q May 22, 2024
4f3ee09
Added license identifier
r59q May 22, 2024
e4a9e28
Merge branch 'main' into 469-generalise-the-data-representation
r59q May 22, 2024
e1ec8e6
Fixed pipeline
r59q May 22, 2024
19a5e0a
stop if error
r59q May 22, 2024
a002be5
Simplified workflow
r59q May 22, 2024
28f8c33
Merge pull request #485 from microbit-foundation/469-generalise-the-d…
r59q May 22, 2024
3402521
Merge pull request #487 from microbit-foundation/467-fix-prettier-check
r59q May 22, 2024
18fe90b
Ran prettier
r59q May 23, 2024
a4fdf69
Merge pull request #491 from microbit-foundation/488-fix-formatting-a…
r59q May 23, 2024
feb70b5
Using ci instead of i
r59q May 23, 2024
c6ea397
Ignore bad files
r59q May 23, 2024
d0828f2
Merge branch 'main' into v3.2
r59q May 23, 2024
ef25c9a
Changed the makecode hex to use the new version
r59q May 27, 2024
ea058b7
Merge pull request #493 from microbit-foundation/492-update-makecode-…
r59q May 27, 2024
9afcab9
Fix noname use-same feature
r59q May 27, 2024
54484b9
Create filters list
r59q May 27, 2024
d5af988
Merge pull request #494 from microbit-foundation/471-create-a-filters…
r59q May 27, 2024
5678180
Add license identifier
r59q May 27, 2024
3f0e507
Ran prettier
r59q May 27, 2024
f341c25
Revert branding
r59q May 27, 2024
f5774ee
Add hover preview to filters
r59q May 28, 2024
24bffeb
revert brand
r59q May 28, 2024
03f5f97
Merge pull request #495 from microbit-foundation/470-add-hover-effect…
r59q May 28, 2024
d5f1a4d
Added some more icons
r59q May 28, 2024
2f6eb6f
Navigate by clicking filter preview
r59q May 28, 2024
45e0461
Improved the selected model logic
r59q May 28, 2024
2fe195b
Fix pipe
r59q May 28, 2024
af5358f
update prcomment
r59q May 28, 2024
ae79d27
Tabification
r59q May 29, 2024
512a623
Fix flicker
r59q Jun 3, 2024
be188a3
Refactoring training page
r59q Jun 3, 2024
7539399
Fix issues with knn
r59q Jun 4, 2024
853275b
embed the controls in plot
r59q Jun 4, 2024
23576b2
fix test
r59q Jun 4, 2024
fe92aa0
Ran prettier
r59q Jun 4, 2024
42f7146
used unused variable
r59q Jun 4, 2024
0bbc1e0
Removed irrelevant comment
r59q Jun 4, 2024
0f38751
Remove deprecated objects
r59q Jun 4, 2024
18455a8
Run prettier
r59q Jun 4, 2024
7b3fa67
Merge pull request #496 from microbit-foundation/463-split-knn-and-nn…
r59q Jun 4, 2024
c5474b4
Fix dockerfile
r59q Jun 26, 2024
fa0f18d
Added colors to gestures
r59q Jul 3, 2024
604dfc8
Merge pull request #504 from microbit-foundation/462-proposition-addi…
r59q Jul 3, 2024
6751f25
Enforce correct storage version
r59q Jul 3, 2024
7993656
Fixed npe
r59q Jul 3, 2024
6343850
Merge pull request #505 from microbit-foundation/462-proposition-addi…
r59q Jul 3, 2024
e8c8b62
Remove unused var
r59q Jul 3, 2024
b31b55b
Prettier
r59q Jul 3, 2024
fcd4ed2
Added lossGraph to features.json
r59q Jul 8, 2024
d789009
Merge pull request #506 from microbit-foundation/501-add-loss-graph-f…
r59q Jul 8, 2024
673d08a
Prettier
r59q Jul 8, 2024
382dc11
Disabled training page tabs when knn model is disabled
r59q Jul 9, 2024
cf4d8bf
Prettier
r59q Jul 9, 2024
e080dc8
Merge pull request #507 from microbit-foundation/502-remove-tabs-from…
r59q Jul 9, 2024
694d87e
Make K configurable
r59q Jul 10, 2024
7dbe151
Prettier
r59q Jul 11, 2024
f6939d3
Merge pull request #509 from microbit-foundation/500-add-option-to-ch…
r59q Jul 11, 2024
3fc60ea
Remove unused imports
r59q Jul 16, 2024
67c9853
Cleanup: Remove logs
r59q Jul 16, 2024
25b21e7
PRettier
r59q Jul 30, 2024
f33a49b
Create confidences store
r59q Jul 30, 2024
01d8ef0
Rework confidences
r59q Jul 30, 2024
0aa8618
Merge pull request #510 from microbit-foundation/refactor-confidence
r59q Jul 30, 2024
c8f164b
Add check to test number of samples required by filters
r59q Jul 30, 2024
928f1e5
Merge pull request #511 from microbit-foundation/min-samples-check
r59q Jul 30, 2024
e4bf3c5
Fix bugs where wrongly axes were selected and model wasn't trained co…
r59q Jul 31, 2024
e438392
Ensure no axes are highlighted when training neural network
r59q Jul 31, 2024
15519d7
Prettier and unbranded config
r59q Jul 31, 2024
ab0a13b
Formatting
r59q Jul 31, 2024
3d3b543
Identified as outdated is disabled
r59q Aug 12, 2024
2e2aaef
Merge pull request #517 from microbit-foundation/516-outdated-firmwar…
r59q Aug 12, 2024
1aa89f0
Disabled bad firmware warning
r59q Aug 12, 2024
16206a6
Merge pull request #518 from microbit-foundation/516-outdated-firmwar…
r59q Aug 12, 2024
c9f4163
Allow custom colors and add graph colors to axis selector
r59q Aug 12, 2024
31b9cf7
Merge pull request #519 from microbit-foundation/515-add-colors-to-th…
r59q Aug 12, 2024
6da563f
Fix KNN graph, data outside graph area
r59q Aug 13, 2024
136c1ff
Prettier
r59q Aug 13, 2024
59f1422
Added comments
r59q Aug 13, 2024
bffef8b
Changed the default scale
r59q Aug 14, 2024
55a4ae5
Added comment and prettier
r59q Aug 21, 2024
5f6a1e0
Changed biuild command to using branded version
Aug 28, 2024
833e6a3
Add explanatory text to training page
r59q Sep 17, 2024
b0fe972
Select better gesture colors
r59q Sep 17, 2024
3c9f535
Moved the classes in standard button to a div inside
r59q Sep 17, 2024
976c956
Ran prettier
r59q Sep 17, 2024
f0c4429
Only put Z
r59q Sep 17, 2024
1fe3105
Fixed problematic uses of buttons
r59q Sep 17, 2024
4734e84
Merge branch 'v3.2' into v3.2-single-axis
r59q Sep 17, 2024
f240afa
Add only Z-axis
r59q Sep 17, 2024
2c63201
Map non-existant values to 0
r59q Sep 17, 2024
f888206
Logging
r59q Sep 23, 2024
7d45b97
Better styling
r59q Sep 23, 2024
446db70
Fix stability issues
r59q Sep 23, 2024
4e67171
Standard filter tweaks
r59q Sep 23, 2024
9b932cf
x
r59q Sep 23, 2024
7134e58
Changed to simple build
Sep 24, 2024
d64046b
Remove the pr comment workflow
r59q Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactoring training page
r59q committed Jun 3, 2024

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
commit be188a381366e141de07ce5fb4511bcf49f87d92
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
"a11y-structure": "ignore",
"a11y-click-events-have-key-events": "ignore",
"a11y-missing-content": "ignore",
"a11y-no-noninteractive-element-interactions":"ignore",
"a11y-no-noninteractive-element-interactions": "ignore",
"a11y-no-static-element-interactions": "ignore"
},
"files.exclude": {
@@ -34,4 +34,4 @@
"**/Thumbs.db": true
},
"hide-files.files": []
}
}
Original file line number Diff line number Diff line change
@@ -16,17 +16,17 @@
</script>

<div>
<p class="text-center text-2xl bold m-auto">
<p class="text-center text-xl bold m-auto">
{$t('menu.trainer.notConnected1')}
</p>
<p class="text-center text-2xl bold m-auto">
<p class="text-center text-xl bold m-auto">
{$t('menu.trainer.notConnected2')}
</p>
<div class="text-center ml-auto mr-auto mb-2 mt-2">
<img
class="m-auto arrow-filter-color"
src="/imgs/down_arrow.svg"
alt="down arrow icon"
width="50px" />
width="35px" />
</div>
</div>
4 changes: 1 addition & 3 deletions src/components/graphs/knngraph/KNNModelGraphController.ts
Original file line number Diff line number Diff line change
@@ -3,9 +3,8 @@
*
* SPDX-License-Identifier: MIT
*/
import * as d3 from 'd3';
import { TrainingData } from '../../../script/domain/ModelTrainer';
import { Unsubscriber, Writable, derived, get, writable } from 'svelte/store';
import { Writable, derived, get, writable } from 'svelte/store';
import KNNModelGraphDrawer, { GraphDrawConfig } from './KNNModelGraphDrawer';
import {
MicrobitAccelerometerData,
@@ -17,7 +16,6 @@ import Filters from '../../../script/domain/Filters';
import { Point3D } from '../../../script/utils/graphUtils';
import StaticConfiguration from '../../../StaticConfiguration';
import { stores } from '../../../script/stores/Stores';
import { LiveDataVector } from '../../../script/domain/stores/LiveDataVector';

type SampleData = {
value: number[];
4 changes: 2 additions & 2 deletions src/pages/DataPage.svelte
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
import NewGestureButton from '../components/NewGestureButton.svelte';
import StandardButton from '../components/buttons/StandardButton.svelte';
import { startConnectionProcess } from '../script/stores/connectDialogStore';
import PleaseConnectFirst from '../components/PleaseConnectFirst.svelte';
import DataPageControlBar from '../components/datacollection/DataPageControlBar.svelte';
import Information from '../components/information/Information.svelte';
import { onMount } from 'svelte';
@@ -23,6 +22,7 @@
import exampleDataset from '../exampleDataset.json';
import { GestureData } from '../script/domain/stores/gesture/Gesture';
import { stores } from '../script/stores/Stores';
import PleaseConnect from '../components/PleaseConnect.svelte';

let isConnectionDialogOpen = false;
const gestures = stores.getGestures();
@@ -89,7 +89,7 @@
</div>
{#if !hasSomeData() && !$state.isInputConnected}
<div class="mt-4">
<PleaseConnectFirst />
<PleaseConnect />
</div>
{:else}
<div class="mt-4 ml-3">
4 changes: 2 additions & 2 deletions src/pages/model/stackview/ModelPageStackView.svelte
Original file line number Diff line number Diff line change
@@ -14,9 +14,9 @@
import Microbits from '../../../script/microbit-interfacing/Microbits';
import TrainModelFirstTitle from '../../../components/TrainModelFirstTitle.svelte';
import ModelPageStackViewContent from './ModelPageStackViewContent.svelte';
import PleaseConnectFirst from '../../../components/PleaseConnectFirst.svelte';
import StaticConfiguration from '../../../StaticConfiguration';
import { stores } from '../../../script/stores/Stores';
import PleaseConnect from '../../../components/PleaseConnect.svelte';

const classifier = stores.getClassifier();
// In case of manual classification, variables for evaluation
@@ -83,7 +83,7 @@
{#if $state.isInputReady}
<ModelPageStackViewContent />
{:else}
<PleaseConnectFirst />
<PleaseConnect />
{/if}
{:else}
<TrainModelFirstTitle />
19 changes: 19 additions & 0 deletions src/pages/training/InsufficientData.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!--
(c) 2023, center for computational thinking and design at aarhus university and contributors

spdx-license-identifier: mit
-->
<script lang="ts">
import { t } from './../../i18n';
</script>

<div class="flex flex-col h-full justify-center">
<div class="flex flex-col">
<h1 class="text-3xl bold m-auto">
{$t('menu.trainer.notEnoughDataHeader1')}
</h1>
<p class="text-xl m-auto">
{$t('menu.trainer.notEnoughDataInfoBody')}
</p>
</div>
</div>
143 changes: 143 additions & 0 deletions src/pages/training/KnnModelTrainingPageView.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<!--
(c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors

SPDX-License-Identifier: MIT
-->
<script lang="ts">
import { onMount } from 'svelte';
import { get } from 'svelte/store';
import ClassifierFactory from '../../script/domain/ClassifierFactory';
import { stores } from '../../script/stores/Stores';
import { extractAxisFromTrainingData } from '../../script/utils/graphUtils';
import { TrainingData } from '../../script/domain/ModelTrainer';
import {
highlightedAxis,
prevHighlightedAxis,
selectedModel,
state,
} from '../../script/stores/uiStore';
import Axes from '../../script/domain/Axes';
import * as d3 from 'd3';
import KNNModelGraphController, {
controller,
} from '../../components/graphs/knngraph/KNNModelGraphController';
import AxesFilterVectorView from '../../components/graphs/knngraph/AxesFilterVectorView.svelte';
import StaticConfiguration from '../../StaticConfiguration';
import KnnModelGraphSvgWithControls from '../../components/graphs/knngraph/KnnModelGraphSvgWithControls.svelte';
import KnnPointToolTipView from '../../components/graphs/knngraph/KnnPointToolTipView.svelte';
import { trainModel } from './TrainingPage';
import ModelRegistry from '../../script/domain/ModelRegistry';

const classifierFactory = new ClassifierFactory();

const classifier = stores.getClassifier();
const gestures = stores.getGestures();
const confidences = gestures.getConfidences();

const canvasWidth = 550;
const canvasHeight = 350;

// Cache training data to avoid fetching them again and again
const allData = classifierFactory.buildTrainingData(
gestures.getGestures(),
classifier.getFilters(),
);

const accelXData = extractAxisFromTrainingData(allData, 0, 3);
const accelYData = extractAxisFromTrainingData(allData, 1, 3);
const accelZData = extractAxisFromTrainingData(allData, 2, 3);

const dataGetter = (): TrainingData => {
const axis = get(highlightedAxis);
if (axis === Axes.X) {
return accelXData;
}
if (axis === Axes.Y) {
return accelYData;
}
if (axis === Axes.Z) {
return accelZData;
}
throw new Error('Should not happen');
};

const initSingle = (axis: Axes) => {
const svgSingle = d3.select('.d3-3d-single');
const controller = new KNNModelGraphController(
svgSingle,
() => dataGetter(),
{ x: canvasWidth / 2, y: canvasHeight / 2 },
'd3-3d-single-',
axis,
);
return controller;
};

$: {
if ($highlightedAxis) {
if (get(controller)) {
get(controller)!.destroy();
}
controller.set(initSingle($highlightedAxis));
} else {
$highlightedAxis = Axes.X;
}
}

onMount(() => {
controller.set(initSingle(Axes.X));
return () => {
get(controller)?.destroy();
};
});
// Should be in KNNModelGraph instead
onMount(() => {
const unsubscribe = highlightedAxis.subscribe(axis => {
if ($selectedModel.id === 'KNN') {
if (!axis) {
return;
}
if ($prevHighlightedAxis === axis) {
return;
}
trainModel(ModelRegistry.KNN);
prevHighlightedAxis.set(axis);
}
});
return unsubscribe;
});
</script>

<div class="flex flex-row" class:hidden={!$classifier.model.isTrained}>
<div class="flex flex-col justify-center mr-6">
<AxesFilterVectorView />
<div class="flex flex-col ml-2 justify-center mt-2">
{#each $gestures as gesture, index}
<div class="flex flex-row justify-between">
<div class="flex flex-row">
<div class="flex flex-col justify-center mr-1">
<div
class="rounded-full w-3 h-3"
style={'background-color:' + StaticConfiguration.gestureColors[index]} />
</div>
<p>{gesture.name}</p>
</div>
{#if $state.isInputReady}
<p>
{(($confidences.get(gesture.ID)?.currentConfidence ?? 0) * 100).toFixed(2)}%
</p>
{/if}
</div>
{/each}
</div>
</div>
<div class="relative">
<KnnModelGraphSvgWithControls
hidden={false}
height={canvasHeight}
width={canvasWidth}
classID={'d3-3d-single'}
controller={$controller} />
<KnnPointToolTipView />
</div>
</div>
54 changes: 54 additions & 0 deletions src/pages/training/NeuralNetworkTrainingPageView.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!--
(c) 2023, center for computational thinking and design at aarhus university and contributors

spdx-license-identifier: mit
-->
<script lang="ts">
import { stores } from '../../script/stores/Stores';
import { loss, trainModel } from './TrainingPage';
import { t } from './../../i18n';
import LossGraph from '../../components/graphs/LossGraph.svelte';
import StaticConfiguration from '../../StaticConfiguration';
import StandardButton from '../../components/buttons/StandardButton.svelte';
import ModelRegistry from '../../script/domain/ModelRegistry';
import Logger from '../../script/utils/Logger';

const classifier = stores.getClassifier();
const model = classifier.getModel();

const trainModelClickHandler = () => {
trainModel(ModelRegistry.NeuralNetwork).then(() => {
Logger.log('NeuralNetworkTrainingPageView', 'Model trained');
});
};

$: trainButtonSimpleLabel = !$model.hasModel
? 'menu.trainer.trainModelButtonSimple'
: 'menu.trainer.trainNewModelButtonSimple';
</script>

<div class="flex flex-col flex-grow justify-center items-center text-center">
<div class="mt-10">
{#if $model.isTraining}
<div class="ml-auto mr-auto flex center-items justify-center">
<i
class="fa fa-solid fa-circle-notch text-5xl animate-spin animate-duration-[2s]" />
</div>
{:else}
<StandardButton onClick={trainModelClickHandler}
>{$t(trainButtonSimpleLabel)}</StandardButton>
{/if}
{#if $loss.length > 0}
<div class="flex flex-col flex-grow justify-center items-center text-center">
<div class="w-3/4 text-primarytext">
<p class="bold text-3xl bold mt-10">
{$t('menu.trainer.isTrainingModelButton')}
</p>
</div>
</div>
<LossGraph
{loss}
maxX={StaticConfiguration.layersModelTrainingSettings.noOfEpochs} />
{/if}
</div>
</div>
Loading