Skip to content

Commit 274aeef

Browse files
committed
fix(lib): Fix splitTest not correctly translating to test data length
1 parent 88331e5 commit 274aeef

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/splitTestData.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ const splitTestData = (
55
labels: CsvTable,
66
splitTest: true | number
77
) => {
8-
const length =
8+
const dataLength = features.length;
9+
const testLength =
910
typeof splitTest === 'number'
10-
? Math.max(0, Math.min(splitTest, features.length - 1))
11+
? Math.max(0, Math.min(splitTest, dataLength))
1112
: Math.floor(features.length / 2);
13+
const testStartIndex = dataLength - testLength;
1214

1315
return {
14-
testFeatures: features.slice(length),
15-
testLabels: labels.slice(length),
16-
features: features.slice(0, length),
17-
labels: labels.slice(0, length),
16+
features: features.slice(0, testStartIndex),
17+
labels: labels.slice(0, testStartIndex),
18+
testFeatures: features.slice(testStartIndex),
19+
testLabels: labels.slice(testStartIndex),
1820
};
1921
};
2022

0 commit comments

Comments
 (0)