## ------------------------------------------------
## Method `RandomForestRegressor$new`
## ------------------------------------------------
rf <- RandomForestRegressor$new()
rf <- RandomForestRegressor$new(n_estimators = 500)
rf <- RandomForestRegressor$new(n_estimators = 500, random_state = 100)
## ------------------------------------------------
## Method `RandomForestRegressor$fit`
## ------------------------------------------------
data(abalone)
split_list <- train_test_split(abalone[1:100,], 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 <- RandomForestRegressor$new()
rf$fit(X_train, y_train)
## ------------------------------------------------
## Method `RandomForestRegressor$predict`
## ------------------------------------------------
preds <- rf$predict(X_test)
print(head(matrix(c(y_test, preds), ncol = 2, dimnames = (list(NULL, c("True", "Prediction"))))))
## ------------------------------------------------
## Method `RandomForestRegressor$get_estimator_type`
## ------------------------------------------------
rf$get_estimator_type()
Run the code above in your browser using DataLab