Skip to content

Commit 6798844

Browse files
committed
Fix false classifier input bug
1 parent daee32a commit 6798844

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/script/domain/ClassifierInput.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,11 @@ export class ClassifierInput {
1313
if (this.samples.length === 0) {
1414
return [];
1515
}
16-
1716
const vectorSize = this.samples[0].getSize();
18-
const inputUnfiltered: number[][] = new Array(vectorSize).fill([]);
19-
20-
this.samples.forEach(smpl =>
21-
smpl.getVector().forEach((k, idx) => {
22-
inputUnfiltered[idx].push(k);
23-
}),
24-
);
2517

26-
return inputUnfiltered.flatMap(e => filters.compute(e));
18+
return Array.from({ length: vectorSize }, (_, i) =>
19+
filters.compute(this.samples.map(e => e.getVector()[i])),
20+
).flat();
2721
}
2822

2923
public getNumberOfSamples(): number {

src/script/domain/stores/HighlightedAxes.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
*
44
* SPDX-License-Identifier: MIT
55
*/
6-
import { derived, get, type Readable, type Unsubscriber, type Writable } from 'svelte/store';
6+
import {
7+
derived,
8+
get,
9+
type Readable,
10+
type Unsubscriber,
11+
type Writable,
12+
} from 'svelte/store';
713
import Classifier from './Classifier';
814
import { type Subscriber } from 'svelte/motion';
915
import SelectedModel from '../SelectedModel';
@@ -54,7 +60,7 @@ class HighlightedAxes implements Writable<Axis[]> {
5460
invalidate?: (value?: Axis[]) => void,
5561
): Unsubscriber {
5662
return derived([this.value], ([store]) => {
57-
return [...store].toSorted((a, b) => a.index - b.index)
63+
return [...store].toSorted((a, b) => a.index - b.index);
5864
}).subscribe(run, invalidate);
5965
}
6066

src/script/repository/LocalStorageTrainingDataRepository.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import { stores } from '../stores/Stores';
1414
import type { LocalStorageFiltersRepository } from './LocalStorageFiltersRepository';
1515

1616
class LocalStorageTrainingDataRepository implements TrainingDataRepository {
17-
constructor(private repositories: Repositories, private filtersRepository: LocalStorageFiltersRepository) { }
17+
constructor(
18+
private repositories: Repositories,
19+
private filtersRepository: LocalStorageFiltersRepository,
20+
) {}
1821

1922
public getTrainingData(): TrainingData {
2023
const gestures = get(this.repositories.getGestureRepository());

0 commit comments

Comments
 (0)