new constructor(options: object, model: object)
Parameters
options (object) Same parameters described here , Default parameters below.
Name Description
options.booster string (default 'gbtree')
options.objective string (default 'reg:linear')
options.max_depth number (default 5)
options.eta number (default 0.1)
options.min_child_weight number (default 1)
options.subsample number (default 0.5)
options.colsample_bytree number (default 1)
options.silent number (default 1)
options.iterations number (default 200)
model (object) for load purposes.

Free the memory allocated for the model. Since this memory is stored in the memory model of emscripten, it is allocated within an ArrayBuffer and WILL NOT BE GARBARGE COLLECTED, you have to explicitly free it. So not calling this will result in memory leaks. As of today in the browser, there is no way to hook the garbage collection of the XGBoost object to free it automatically. Free the memory that was created by the compiled XGBoost library to. store the model. This model is reused every time the predict method is called.

free()

Predicts the output given the matrix to predict.

predict(toPredict: (Matrix | Array<Array<number>>)): Array<number>
Parameters
toPredict ((Matrix | Array<Array<number>>))
Returns
Array<number>: 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 | Array<Array<number>>), trainingValues: Array<number>)
Parameters
trainingSet ((Matrix | Array<Array<number>>))
trainingValues (Array<number>)

Load a Decision tree classifier with the given model.

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

loadFromModel

src/loadXGBoost.js

Load a model trained from other programming language

loadFromModel(filepath: string, options: object): XGBoost
Parameters
filepath (string)
options (object = {})
Name Description
options.labels Array? Some classifiers are trained with a one-hot encoder (Ex: Python API) so the current classifier returns the probability of each class, if you want the single predictions, you should provide an array with the corresponding labels, if you are doing regression you should ignore this option
Returns
XGBoost: model