Simulating the decision of a bagged tree
Mostrar comentarios más antiguos
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?
1 comentario
Elena Casiraghi
el 3 de Mzo. de 2020
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Classification Ensembles en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!