Question
How can I use the "predictorImportance" function with models generated by applying "crossval" to RegressionTree objects? When I apply the ‘crossval’ function on the results of the ‘fitrtree’ function, I end up with a different class, namely: 'classreg.learning.partition.RegressionPartitionedModel' and am unable to use the 'predictorImportance' function on this object. How do you call 'predictorImportance' on the models generated from 'crossval'?
Expert Answer
Kshitij Singh
PhD Expert
Answered Aug 23, 2026
It is important to note that ‘predictorImportance’ can only be applied to one model at a time. The result of using the “crossval” function on a regression tree will be a set of regression models and thus you will need to index into each of these models to determine the predictor importance.
The following example code which you can execute in the MATLAB command window shows how you can call ‘predictorImportance’ on the results of ‘crossval’
%%Load the sample data.
load carsmall;
%%Construct a regression tree using the sample data.
tree = fitrtree([Weight, Cylinders],MPG,...
'categoricalpredictors',2,'MinParentSize',20,...
'PredictorNames',{'W','C'}) ;
%%cross validation
Ctree = crossval(tree);
% where tree is the original ‘RegressionTree’ object. Note that the default number of folds i.e. regression models generated will be 10
%%Calling predictorImportance on individual regression models
predictorImportance(Ctree.Trained{1})
predictorImportance(Ctree.Trained{10})
% where 1 and 10 represent the indices of the trained models. This would range from 1 to 10 by default
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
Related fitrtree Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →