MATLAB: Random forest prediction probabilities

random forestRFrocroc curvetreetreebagger

Hi,
I trained a random forest model using MATLAB's "TreeBagger" function. However, when I use the "predict" function, my probabilities are all 0 or 1 except for a few predictions. Despite having 4000 observations, my roc curve has also only three data point. Can you suggest any solution for this problem?
Thanks in advance.

Best Answer

Getting a probability of 1 suggests that the model has overfitted, and the observation is being predicted as belonging to the specific class by all trees.
You can overcome this issue by reducing the size of the trees. Few of the options that might help are,
  1. MinLeafSize: Set this to higher value
  2. MaxNumSplits: Set this to a lower value
You can also try to use fitcensemble instead. See TreeBagger and fitcensemble for more details.
Alternately, you may want to use a different approach entirely, by using SVMs or other classifiers.
Related Question