Predictor Importance for Bagged Trees in Classification Learner App??

Ciara Sypherd · Apr 9, 2022 · 1.9K views
Question
Hello,   I have sucessfully used BaggedTrees in the classificationLearner app to classify my data. I would now like to know (and show) which of my predictors are most useful in determining class. How can I do this?   The scatter plots generated in the app are helpful, but not what I am looking for. I want something like a bar graph that shows the most and least relevant predictors, or ideally a decision tree which shows which predictors give the greatest class separations.   I have found examples of this with different set ups, but I can't figure out how to make them work for me. The command I have seen to make decision trees is: view(trainedModel.ClassificationTree,'Mode','graph')   I have also seen the predictor importance found using: imp = predictorImportance(ens)   However, these methods have not worked for me. My code is simply a data importation and the command to call the classifier: fit = trainedModel2.predictFcn(Table);   Any help would be HUGELY appreciated.
Expert Answer
Profile picture of John Michell
John Michell PhD Expert
Answered Aug 20, 2026
Hi,
 
"I have sucessfully used BaggedTrees in the classificationLearner app to classify my data..."
 
 
1. Make sure to have exported the model (not the compact model) from the classification learner app. Then you find something like this by double click on your trained model in workspace. Important is that you have a ClassificationBaggedEnsemble:
 
model1.PNG
2. If you have this model as a ClassificationBaggedEnsemble in your workspace, you can use:
 
Importance = oobPermutedPredictorImportance(trainedModel.ClassificationEnsemble);
bar(Importance)

 

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!