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

    %% Predictor Importance and Surrogate Splits
% Estimate the predictor importance for all variables in the data and where
% the regression tree ensemble contains surrogate splits.
%%
% Load the |carsmall| data set.
load carsmall
%%
% Grow an ensemble of 100 regression trees for |MPG| using |Acceleration|, |Cylinders|,
% |Displacement|, |Horsepower|, |Model_Year|, and |Weight| as predictors.
% Specify to identify surrogate splits.
X = [Acceleration Cylinders Displacement Horsepower Model_Year Weight];
t = templateTree('Surrogate','on');
ens = fitensemble(X,MPG,'LSBoost',100,t);
%%
% Estimate the predictor importance and predictive measures of importance
% for all predictor variables.
[imp,ma] = predictorImportance(ens)
%%
% Comparing |imp| to the results in <docid:stats_ug.bu4moyj>, |Horsepower|
% has the greatest impact on mileage, with |Weight| having the second greatest
% impact.