# How can I use the “predictorImportance” function with models

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’?

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

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 validationCtree = crossval(tree);% where tree is the original ‘RegressionTree’ object.`

--

--

## More from Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

Love podcasts or audiobooks? Learn on the go with our new app.

## Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.