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 carsmall;
tree = fitrtree([Weight, Cylinders],MPG,...
'categoricalpredictors',2,'MinParentSize',20,...
'PredictorNames',{'W','C'}) ;
Ctree = crossval(tree);
predictorImportance(Ctree.Trained{1})
predictorImportance(Ctree.Trained{10})
For more information on how to use the ‘fitrtree’ function please refer to the following link:
Best Answer