View the tree ensemble trained by fitcensemble
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Puru Kathuria
2020-3-6
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!