www.gusucode.com > stats 源码程序 matlab案例代码 > stats/EstimatePredictorImportanceRegExample.m

    %% Estimate Predictor Importance
% Estimate the predictor importance for all predictor variables in the
% data.
%%
% Load the |carsmall| data set.
load carsmall
%%
% Grow a regression tree for |MPG| using |Acceleration|, |Cylinders|,
% |Displacement|, |Horsepower|, |Model_Year|, and |Weight| as predictors.
X = [Acceleration Cylinders Displacement Horsepower Model_Year Weight];
tree = fitrtree(X,MPG);
%%
% Estimate the predictor importance for all predictor variables.
imp = predictorImportance(tree)
%%
% |Weight|, the last predictor, has the most impact on mileage. The second
% predictor has importance 0, which means that the number of cylinders has
% no impact on predictions made with |tree|.