Can I use the fitcensemble function to create a Random Forest model?

6 views (last 30 days)
I am new to machine learning classifiers.
I want to develop a Random Forest classification model with my IMU data.
I used the code below, and my question is: Can I call it a Random Forest model, or should I just call it a bagging ensemble model?
baggedEnsemble = fitcensemble(data_train(:,2:end), data_train(:,1),'Method','Bag','NumLearningCycles',100);

Answers (1)

Govind KM
Govind KM on 9 Sep 2024
Hi Junwoo,
The primary characteristic of a Random Forest model is to use random subsets of predictors to train individual trees. In the “fitcensemble” function, if the “Method” parameter is passed as “Bag”, then by default the function uses bagging with decision trees as the base learners, utilizing random predictor selections at each split (Square root of the number of predictors by default). This makes it effectively the same as a Random Forest model.
To use bagging without the random selections, the “NumVariablesToSample” parameter can be set to “all”. The Ensemble aggregation method or the weak learners can also be changed as required to make the model created through the “fitcensemble” function different from a Random Forest model. You can refer to the documentation for more details on different options for the ensemble model, including ensemble method and weak learners:
Hope this resoves the confusion.

Products


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!