Create new Decision Tree Regression with CART implementation with the given options.

constructor(options: object, model: object)
Parameters
options (object)
Name Description
options.gainFunction string (default "regression") gain function to get the best split, "regression" the only one supported.
options.splitFunction string (default "mean") given two integers from a split feature, get the value to split, "mean" the only one supported.
options.minNumSamples number (default 3) minimum number of samples to create a leaf node to decide a class.
options.maxDepth number (default Infinity) Max depth of the tree.
model (object) for load purposes.

Predicts the values given the matrix to predict.

predict(toPredict: (Matrix | MatrixTransposeView | Array)): Array
Parameters
toPredict ((Matrix | MatrixTransposeView | Array))
Returns
Array: predictions

Export the current model to JSON.

toJSON(): object
Returns
object: Current model.

Train the decision tree with the given training set and values.

train(trainingSet: (Matrix | MatrixTransposeView | Array), trainingValues: Array)
Parameters
trainingSet ((Matrix | MatrixTransposeView | Array))
trainingValues (Array)

Load a Decision tree regression with the given model.

load(model: object): DecisionTreeRegression
Parameters
model (object)
Returns
DecisionTreeRegression:

Create new Decision Tree Classifier with CART implementation with the given options

new constructor(options: object, model: object)
Parameters
options (object)
Name Description
options.gainFunction string (default "gini") gain function to get the best split, "gini" the only one supported.
options.splitFunction string (default "mean") given two integers from a split feature, get the value to split, "mean" the only one supported.
options.minNumSamples number (default 3) minimum number of samples to create a leaf node to decide a class.
options.maxDepth number (default Infinity) Max depth of the tree.
model (object) for load purposes.

Predicts the output given the matrix to predict.

predict(toPredict: (Matrix | MatrixTransposeView | Array)): Array
Parameters
toPredict ((Matrix | MatrixTransposeView | Array))
Returns
Array: predictions

Export the current model to JSON.

toJSON(): object
Returns
object: Current model.

Train the decision tree with the given training set and labels.

train(trainingSet: (Matrix | MatrixTransposeView | Array), trainingLabels: Array)
Parameters
trainingSet ((Matrix | MatrixTransposeView | Array))
trainingLabels (Array)

Load a Decision tree classifier with the given model.

load(model: object): DecisionTreeClassifier
Parameters
model (object)
Returns
DecisionTreeClassifier: