model_selection.KFold
Usage
import { KFold } from 'machinelearn/model_selection';
const kFold = new KFold({ k: 5 });
const X1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
console.log(kFold.split(X1, X1));
/* [ { trainIndex: [ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ],
* testIndex: [ 0, 1, 2, 3 ] },
* { trainIndex: [ 0, 1, 2, 3, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ],
* testIndex: [ 4, 5, 6, 7 ] },
* { trainIndex: [ 0, 1, 2, 3, 4, 5, 6, 7, 12, 13, 14, 15, 16, 17, 18, 19 ],
* testIndex: [ 8, 9, 10, 11 ] },
* { trainIndex: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 17, 18, 19 ],
* testIndex: [ 12, 13, 14, 15 ] },
* { trainIndex: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ],
* testIndex: [ 16, 17, 18, 19 ] } ]
Constructors
Methods
Constructors
constructor
⊕ KFold(__namedParameters: `object`)
Defined in model_selection/_split.ts:43
Parameters:
Param | Type | Default | Description |
---|---|---|---|
options.k | number | 2 | |
options.shuffle | boolean | false |
Returns: KFold
Methods
λ split
Defined in model_selection/_split.ts:57
Parameters:
Param | Type | Default | Description |
---|---|---|---|
X | any[] | null | Training data, where n_samples is the number of samples and n_features is the number of features. |
y | any[] | null | The target variable for supervised learning problems. |
Returns:
any[]