How to use random forest method

35 views (last 30 days)
Kanakaiah Jakkula
Kanakaiah Jakkula on 2 Mar 2018
Commented: Jan Startek on 17 Mar 2021
Hi, Below is my training data (v1,v2,v3 are process variables, and Y is the response variable,
Based on training data, given set of new v1,v2,v3, and predict Y. I want to make prediction using "Random forest tree bag" (decisiotn tree regression) method.
Training data:
v1 v2 v3 Y
16.00 21.05 25.01 8
14.44 22.79 27.02 1
14.69 21.83 25.10 1
15.32 21.09 28.35 4
15.22 23.38 28.11 2
14.6 22.77 27.8 3
15.52 22.33 27.78 0
15.30 22.28 28.18 0
15.47 20.94 28.14 5
14.04 23.41 25.22 9
15.67 20.89 28.97 8
14.14 20.73 26.22 6
14.80 20.87 25.82 2
14.63 22.33 27.03 0
15.66 22.22 28.22 1
14.40 20.73 28.13 7
14.09 21.04 26.25 5
14.61 23.48 26.24 4
14.63 22.33 27.03 0
15.53 22.79 28.37 6
14.51 22.78 28.8 5
15.76 23.27 26.62 3
15.42 21.68 27.59 0
Make prediction for below two set of test data, what Y
test data:
v1 v2 v3
15.29 21.39 27.07
14.53 23.18 26.31

Answers (1)

Bernhard Suhm
Bernhard Suhm on 2 Apr 2018
You could read your data into the Classification Learner app (New Session - from File), and then train a "Bagged Tree" on it (that's how we refer to random forests). However, given how small this data set is, the performance will be terrible.
  3 Comments
Javaid Iqbal
Javaid Iqbal on 4 Jul 2018
Sir may you please help me regarding SVM classification. When I use predict test data I'm unable predict thr right solutions.
yfit=trainedModel.predictFcn(T);
I got result yfit=0 as predicted but when it should give yfit=1 result for tru value but this showing same yfit=0
Jan Startek
Jan Startek on 17 Mar 2021
Does Bagged Tree really use a ranfom forest algorithm ( Breiman random forest? ). My point is I don't see where in the code a random variable selection for each node in grown trees is perforemd. TreeBagger (https://se.mathworks.com/help/stats/treebagger.html#bvf7_tc-1) seems to have such an option with the use of "'NumPredictorsToSample'" however I can't find an analogus option in TreeBagger.
My question boils down to, is there a random variable selection performed at each split in the grown trees in the Bagged Trees algorithm in clasifiactionLearner?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!