RandomForest
Extends:
Random forest learner. Builds multiple decision trees with a random subsample of the samples, and averages their predictions for the final prediction model.
Constructor Summary
Public Constructor | ||
public |
constructor(optionsUser: Object, bootstrap: boolean) Constructor. |
Member Summary
Public Members | ||
public |
bootstrap: * |
|
public |
criterion: * |
|
public |
maxDepth: * |
|
public |
numFeatures: * |
|
public |
numTrees: * |
|
public |
trees: *[] |
Method Summary
Public Methods | ||
public |
predict(X: *): * |
|
public |
predictSample(sampleFeatures: Array<number>): mixed Make a prediction for a single sample. |
|
public |
train(X: *, y: *) |
Inherited Summary
From class Estimator | ||
public abstract |
Make a prediction for a data set. |
|
public abstract |
Train the supervised learning algorithm on a dataset. |
Public Constructors
public constructor(optionsUser: Object, bootstrap: boolean) source
Constructor. Initialize class members and store user-defined options.
Params:
Name | Type | Attribute | Description |
optionsUser | Object |
|
User-defined options for random forest |
optionsUser.numTrees | number |
|
Number of decision trees to build |
optionsUser.criterion | string |
|
Splitting criterion. Either 'gini', for the Gini coefficient, or 'entropy' for the Shannon entropy |
optionsUser.numFeatures | number | string |
|
Number of features to subsample at each node. Either a number (float), in which case the input fraction of features is used (e.g., 1.0 for all features), or a string. If string, 'sqrt' and 'log2' are supported, causing the algorithm to use sqrt(n) and log2(n) features, respectively (where n is the total number of features) |
optionsUser.maxDepth | number |
|
Maximum depth of each decision tree. The depth of a decision tree is the number of nodes in the longest path from the decision tree root to a leaf. It is an indicator of the complexity of the tree. Use -1 for no maximum depth |
bootstrap | boolean |
|
Whether to select samples for each tree by bootstrapping. If false, all samples are used for each tree. If true, n samples are drawn with replacement from the full set of samples for each tree (where n is the total number of samples) |
optionsUser.numTrees | number |
|
Number of trees to construct |
Public Members
public bootstrap: * source
public criterion: * source
public maxDepth: * source
public numFeatures: * source
public numTrees: * source
public trees: *[] source
Public Methods
public predict(X: *): * source
Make a prediction for a data set.
Override:
Estimator#predictParams:
Name | Type | Attribute | Description |
X | * |
Return:
* |
public predictSample(sampleFeatures: Array<number>): mixed source
Make a prediction for a single sample.
Return:
mixed | Prediction. Label of class with highest prevalence among k nearest neighbours |
public train(X: *, y: *) source
Train the supervised learning algorithm on a dataset.
Override:
Estimator#trainParams:
Name | Type | Attribute | Description |
X | * | ||
y | * |