www.gusucode.com > stats 源码程序 matlab案例代码 > stats/PredictAResponseUsingARegressionTreeExample.m
%% Predict a Response Using a Regression Tree %% % Load the |carsmall| data set. Consider |Displacement|, |Horsepower|, and % |Weight| as predictors of the response |MPG|. % Copyright 2015 The MathWorks, Inc. load carsmall X = [Displacement Horsepower Weight]; %% % Grow a regression tree using the entire data set. Mdl = fitrtree(X,MPG); %% % Predict the MPG for a car with 200 cubic inch engine displacement, 150 % horsepower, and that weighs 3000 lbs. X0 = [200 150 3000]; MPG0 = predict(Mdl,X0) %% % The regression tree predicts the car's efficiency to be 21.94 mpg.