Home
API
Examples
Github
Home
API
Examples
Github
  • API

    • cluster

      • KMeans
    • datasets

      • Boston
      • HeartDisease
      • Iris
    • decomposition

      • PCA
    • ensemble

      • BaggingClassifier
      • RandomForestClassifier
    • feature_extraction

      • CountVectorizer
    • linear_model

      • Lasso
      • LinearRegression
      • LogisticRegression
      • Ridge
      • SGDClassifier
      • SGDRegressor
    • metrics

      • accuracyScore
      • confusion_matrix
      • mean_absolute_error
      • mean_squared_error
      • mean_squared_log_error
      • zeroOneLoss
    • model_selection

      • KFold
      • train_test_split
    • naive_bayes

      • GaussianNB
      • MultinomialNB
    • neighbors

      • KNeighborsClassifier
    • preprocessing

      • Binarizer
      • Imputer
      • LabelEncoder
      • MinMaxScaler
      • OneHotEncoder
      • PolynomialFeatures
      • add_dummy_feature
      • normalize
    • svm

      • BaseSVM
      • NuSVC
      • NuSVR
      • OneClassSVM
      • SVC
      • SVR
    • tree

      • DecisionTreeClassifier

ensemble.RandomForestClassifier

Usage

import { RandomForestClassifier } from 'machinelearn/ensemble';

const X = [[0, 0], [1, 1], [2, 1], [1, 5], [3, 2]];
const y = [0, 1, 2, 3, 7];

const randomForest = new RandomForestClassifier();
randomForest.fit(X, y);

// Results in a value such as [ '0', '2' ].
// Predictions will change as we have not set a seed value.

Constructors

  • constructor

Properties

  • nEstimator

  • randomState

  • trees

Methods

  • fit

  • fromJSON

  • predict

  • toJSON

Constructors


constructor

⊕ RandomForestClassifier(__namedParameters: `object`)

Defined in ensemble/forest.ts:20

Parameters:

ParamTypeDefaultDescription
options.nEstimatornumber10
options.random_statenumbernull

Returns: RandomForestClassifier

Properties


▸ nEstimator

Defined in ensemble/forest.ts:12

▸ randomState

Defined in ensemble/forest.ts:13

▸ trees

Defined in ensemble/forest.ts:11

Methods


λ fit

Build a forest of trees from the training set (X, y).

Defined in ensemble/forest.ts:45

Parameters:

ParamTypeDefaultDescription
Xnumber[][]nullarray-like or sparse matrix of shape = [n_samples, n_features]
ynumber[]nullarray-like, shape = [n_samples] or [n_samples, n_outputs]

Returns:

void

λ fromJSON

Restore the model from a checkpoint

Defined in ensemble/forest.ts:80

Parameters:

ParamTypeDefaultDescription
options.treesany[]null

Returns:

void

λ predict

Predict class for X.

The predicted class of an input sample is a vote by the trees in the forest, weighted by their probability estimates. That is, the predicted class is the one with highest mean probability estimate across the trees.

Defined in ensemble/forest.ts:126

Parameters:

ParamTypeDefaultDescription
Xnumber[][]nullarray-like or sparse matrix of shape = [n_samples]

Returns:

any[]

λ toJSON

Returning the current model's checkpoint

Defined in ensemble/forest.ts:65

Returns:

ParamTypeDescription
treesany[]Decision trees
Prev
BaggingClassifier