필터 지우기
필터 지우기

Simulating the decision of a bagged tree

조회 수: 2 (최근 30일)
Elena Casiraghi
Elena Casiraghi 2020년 2월 27일
댓글: Elena Casiraghi 2020년 3월 3일
Dear,
could anyone tell me how an object of a treeBagger takes a decision?
Precisely, if I have this code:
dataMat = randi(100, 200, 31) % toy example
labels = logical(randi(1,200,1)); % toy example
numTrees = 7;
mdlRF = TreeBagger(numTrees, dataMat,labels, 'CategoricalPredictors', strcmpi(vartypes, 'categorical'), ...
'PredictorNames', vars, 'PredictorSelection','interaction-curvature', ...
'Surrogate','on', ...
'Reproducible',true);
% new example
xx = randi(100, 1, 31);
pred = predict(mdlRF, xx);
How is pred computed?
The bagged tree has trained 7 trees which are saved in the cell array
mdlRF.Trees
I suppose that I should run a for loop such as this one:
for nL = 1: numTrees;
% each tree is used for predicting
pred(nL) = predict(mdlRF.Trees{nL}, xx)
end
% AFTER THE FOR LOOP VARIABLE pred contains the predictions of the numTrees classifiers
How are the different predictions composed to form the final prediction??
I used the average but it does not work.
Could anyone help me?

채택된 답변

Puru Kathuria
Puru Kathuria 2020년 3월 3일
Hi,
I understand that you want to know how predict function in TreeBagger takes its decision. The function predict returns a cell array of character vectors for classification and a numeric array for regression. By default, predict takes a democratic (nonweighted) average vote from all trees in the ensemble. For more information related to predict and the formula used to compute the predicted response, you can visit the following links:

추가 답변 (0개)

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by