0

I have a random forest model. With getTree function I can get all trees created in my random forest Model. Now I want to check the predictions made by each tree for some observations. For this reason I need to make prediction using each tree of my random forest Model.

I found this question with the same objective. But, unfortunately, this question has not been answered.

https://stackoverflow.com/q/40875489/3834837

Any propositions?

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Mouaici_Med
  • 390
  • 2
  • 19

1 Answers1

0

If you are referring to the randomForest package then you can do this by using predict(...,predict.all=T), which would get you all the predictions for each tree. Then you can select whichever you want.

user2974951
  • 9,535
  • 1
  • 17
  • 24
  • thank you for your answer. So, I get the individual matrix (predict$individual) and I'am wondering if the colmn index corresponds to the real index of the tree in the forest? I mean, did the colmn index can be used in the getTree function to get the right tree (getTree (rfModel, k= index))? – Mouaici_Med Sep 20 '19 at 14:18
  • 1
    @Mouaici_Med Yes, the columns represent the individual trees, you should get the same tree if you use the index from predict on getTree. – user2974951 Sep 23 '19 at 05:57