How to get every tree's prediction value after using "TreeBagger" function

5 次查看(过去 30 天)
Hi guys.
I trained bagging trees using TreeBagger function and set 200 for number of trees.
As I know, TreeBagger's prediction is mean value of 200 trees prediction value.
This is my question. Can I get every 200 tree's prediction value? before TreeBagger determined prediction value.
I need 200 tree's prediction value to ananlye my study but I can't find a way to do it. :(
I would greatly appreciate it if anyone tells me how to solve this problem.
Have a nice day :)

回答(1 个)

KALASH
KALASH 2024-4-4,8:21
Hi Hyeon,
To individually get every tree’s prediction value you can use the ‘oobPredict’ method.
The ‘oobPredict’ method allows you to obtain the out-of-bag predictions made by each tree in the ensemble.
% ………..your code……….
yourModel = TreeBagger(numTrees, X, Y, ….)
% use one of the following two syntaxes depending on whichever works to get oob predictions for each tree
oobPredictions = oobPredict(yourmodel) or oobPredictions = yourmodel.oobPredict()
% …………your remaining code…………..
In the oobPredictions variable, you will have a matrix where each row corresponds to an observation in your dataset, and each column corresponds to the prediction made by a specific tree in the ensemble.
Alternatively, you can check out the following method as well in which you can turn the status for ‘OOBPrediction” attribute in the TreeBagger model as “on”:
Feel free to check out the following links for the “oobPredict” function to get more understanding for the same:

Community Treasure Hunt

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

Start Hunting!

Translated by