## ------------------------------------------------
## Method `RandomForestClassifier$new`
## ------------------------------------------------
rf <- RandomForestClassifier$new()
rf <- RandomForestClassifier$new(n_estimators = 500)
rf <- RandomForestClassifier$new(n_estimators = 500, random_state = 100)
## ------------------------------------------------
## Method `RandomForestClassifier$fit`
## ------------------------------------------------
data(iris)
split_list <- train_test_split(iris, test_size = 0.3)
X_train <- split_list[[1]]
X_test <- split_list[[2]]
y_train <- split_list[[3]]
y_test <- split_list[[4]]
rf <- RandomForestClassifier$new()
rf$fit(X_train, y_train)
## ------------------------------------------------
## Method `RandomForestClassifier$predict`
## ------------------------------------------------
rf <- RandomForestClassifier$new()
rf$fit(X_train, y_train)
preds <- rf$predict(X_test)
rf <- RandomForestClassifier$new()
preds <- rf$fit(X_train, y_train)$predict(X_test)
preds <- RandomForestClassifier$new()$fit(X_train, y_train)$predict(X_test)
print(caret::confusionMatrix(data=preds, reference = factor(y_test)))
## ------------------------------------------------
## Method `RandomForestClassifier$get_estimator_type`
## ------------------------------------------------
rf$get_estimator_type()
Run the code above in your browser using DataLab