model_selection.train_test_split
▸ train_test_split(X: `object`, y: `object`, __namedParameters: `object`)
Usage
import { train_test_split } from 'machinelearn/model_selection';
const X = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]];
const y = [0, 1, 2, 3, 4];
train_test_split(X, y, {
test_size: 0.33,
train_size: 0.67,
random_state: 42
});
/*
* { xTest: [ [ 0, 1 ], [ 8, 9 ] ],
* xTrain: [ [ 4, 5 ], [ 6, 7 ], [ 2, 3 ] ],
* yTest: [ 0, 4 ],
* yTrain: [ 2, 3, 1 ] }
Defined in model_selection/_split.ts:125
Parameters:
Param | Type | Default | Description |
---|---|---|---|
X | any[][] | null | input data |
y | any[] | null | target data |
options.clone | boolean | true | |
options.random_state | number | 0 | |
options.test_size | number | 0.25 | |
options.train_size | number | 0.75 |
Returns:
Param | Type | Description |
---|---|---|
xTest | any[] | undefined |
xTrain | any[] | undefined |
yTest | any[] | undefined |
yTrain | any[] | undefined |