View the tree ensemble trained by fitcensemble
9 views (last 30 days)
Show older comments
Dear, let's suppose I'm training a bagged tree ensemble on the 40 sampe points (29 features per sample)
The GT labels are in the var labels.
I gat a tree mdlRF as follows:
dataSel = rand(40, 29); % just a toy example
labels = logical(randi(1,29,1)); % just a toy example
t = templateTree('PredictorSelection','interaction-curvature','Surrogate','on', ...
'Reproducible',true); % For reproducibility of random predictor selections
mdlRF = fitcensemble(dataSel,labels,'Method','Bag', ...
'CategoricalPredictors',[false true true true true true], 'PredictorNames', vars,...
'NumLearningCycles',30,'Learners',t);
If the trained learner were a simple tree I could have viewed it in graph /text mode with the command:
view(mdlRF, 'Mode', 'graph')
Is there an alternative way to view how the mdlRF makes the decision??
0 Comments
Answers (1)
Puru Kathuria
on 6 Mar 2020
Hi,
I understand that you want to visualize your ensemble after training it on a dataset. You can try replacing 2nd line of code with the following line.
labels = logical(randi(1,40,1)); % Training data points (X) should be equal to training labels (Y)
And the last line with the following line.
view(mdlRF.Trained{1}.CompactRegressionLearner,'Mode','graph'); % Visualising
This might meet your requirements and help you visualize your model.
See Also
Categories
Find more on Classification Ensembles in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!