Skip to content

Commit

Permalink
Added warning for ineffective KNN model
Browse files Browse the repository at this point in the history
  • Loading branch information
r59q committed Mar 25, 2024
1 parent 7d0cd21 commit 64f8240
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/pages/training/TrainModelButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<script lang="ts">
import { t } from '../../i18n';
import { classifier } from '../../script/stores/Stores';
import { classifier, gestures } from '../../script/stores/Stores';
import LayersModelTrainer from '../../script/mlmodels/LayersModelTrainer';
import StaticConfiguration from '../../StaticConfiguration';
import StandardDropdownButton from '../../components/buttons/StandardDropdownButton.svelte';
Expand All @@ -28,13 +28,28 @@
highlightedAxis,
} from '../../script/stores/uiStore';
import Axes from '../../script/domain/Axes';
import Logger from '../../script/utils/Logger';
export let onTrainingIteration: (iteration: LossTrainingIteration) => void;
export let onClick: () => void;
const getModelTrainer = (modelEntry: ModelEntry): ModelTrainer<MLModel> => {
if (modelEntry.id === 'KNN') {
highlightedAxis.set(Axes.X);
const noOfRecordings = gestures
.getGestures()
.map(gesture => gesture.getRecordings().length)
.reduce((prev, cur) => cur + prev, 0);
if (noOfRecordings / 2 < StaticConfiguration.knnNeighbourCount) {
Logger.log(
'TrainModelButton',
'The number of recordings is probably too low for an effective KNN model if using ' +
StaticConfiguration.knnNeighbourCount +
' neighbours ',
);
}
return new KNNModelTrainer(StaticConfiguration.knnNeighbourCount);
}
Expand Down

0 comments on commit 64f8240

Please sign in to comment.