www.gusucode.com > stats 源码程序 matlab案例代码 > stats/ConstructaRegressionTreeExample.m
%% Construct a Regression Tree % Copyright 2015 The MathWorks, Inc. %% % 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'}) %% % Predict the mileage of 4,000-pound cars with 4, 6, and 8 cylinders. mileage4K = predict(tree,[4000 4; 4000 6; 4000 8])