get folds indexes

getFolds(features: Array, k: Number)
Parameters
features (Array)
k (Number = 5) number of folds, a

Performs k-fold cross-validation (KF-CV). KF-CV separates the data-set into k random equally sized partitions, and uses each as a validation set, with all other partitions used in the training set. Observations left over from if k does not divide the number of observations are left out of the cross-validation process.

kFold(Classifier: function, features: Array, labels: Array, classifierOptions: object, k: number): ConfusionMatrix
Parameters
Classifier (function) The classifier's to use for the cross validation. Expect ml-classifier api.
features (Array) The features for all samples of the data-set
labels (Array) The classification class of all samples of the data-set
classifierOptions (object) The classifier options with which the classifier should be instantiated.
k (number) The number of partitions to create
Returns
ConfusionMatrix: The cross-validation confusion matrix

leaveOneOut

src/index.js

Performs a leave-one-out cross-validation (LOO-CV) of the given samples. In LOO-CV, 1 observation is used as the validation set while the rest is used as the training set. This is repeated once for each observation. LOO-CV is a special case of LPO-CV. @see leavePout

leaveOneOut(Classifier: function, features: Array, labels: Array, classifierOptions: object): ConfusionMatrix
Parameters
Classifier (function) The classifier's constructor to use for the cross validation. Expect ml-classifier api.
features (Array) The features for all samples of the data-set
labels (Array) The classification class of all samples of the data-set
classifierOptions (object) The classifier options with which the classifier should be instantiated.
Returns
ConfusionMatrix: The cross-validation confusion matrix

leavePOut

src/index.js

Performs a leave-p-out cross-validation (LPO-CV) of the given samples. In LPO-CV, p observations are used as the validation set while the rest is used as the training set. This is repeated as many times as there are possible ways to combine p observations from the set (unordered without replacement). Be aware that for relatively small data-set size this can require a very large number of training and testing to do!

leavePOut(Classifier: function, features: Array, labels: Array, classifierOptions: object, p: number): ConfusionMatrix
Parameters
Classifier (function) The classifier's constructor to use for the cross validation. Expect ml-classifier api.
features (Array) The features for all samples of the data-set
labels (Array) The classification class of all samples of the data-set
classifierOptions (object) The classifier options with which the classifier should be instantiated.
p (number) The size of the validation sub-samples' set
Returns
ConfusionMatrix: The cross-validation confusion matrix

A function to sample a dataset maintaining classes equilibrated

sampleAClass(classVector: Array, fraction: Number): Object
Parameters
classVector (Array) an array containing class or group information
fraction (Number) a fraction of the class to sample
Returns
Object: an object with indexes