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

    %% Compute the In-Sample MSE
%%
% 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 all observations.
tree = fitrtree(X,MPG);
%%
% Estimate the in-sample MSE.
L = loss(tree,X,MPG)