2
$\begingroup$

There is a function call TreeBagger that can implement random forest. However, if we use this function, we have no control on each individual tree. Can we use the MATLAB function fitctree, which build a decision tree, to implement random forest? Thanks a lot.

$\endgroup$
  • $\begingroup$ Can you specify what it is you want to control? Without looking much at MATLAB specific functions, I would think you can control several tree parameters, such as leaf size. $\endgroup$ – Hobbes Oct 27 '17 at 14:45
  • $\begingroup$ i only want to implement Random forest on my dataset and compare with other classifiers. $\endgroup$ – Case Msee Oct 27 '17 at 14:51
  • $\begingroup$ But why do you want control of each individual tree? $\endgroup$ – Hobbes Oct 27 '17 at 15:04
4
$\begingroup$

I would highly recommend doing some research into the architecture of random forests. There are many sites that provide in depth tutorials on RFs (Implementation in Python).

Quick explanation: take your dataset, bootstrap the samples and apply a decision tree. Within your trees, you want to randomly sample the features at each split. You should not have to build your own RF using fitctree however. You don't want to control each individual tree in the forest. This introduces bias, and the point of the RF is that by bagging many trees, you remove the risk of overfitting.

Define your hyperparameters and let the algorithm do it's thing. Carefully cross-validate to ensure you are not under-fitting.

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Perfect answer , just one small comment , overfitting is related to variance error and not bias error. This introduces variance error. $\endgroup$ – Bashar Haddad Oct 27 '17 at 19:02
  • $\begingroup$ Very true @BasharHaddad, thanks for the clarification! $\endgroup$ – Hobbes Oct 27 '17 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.