www.gusucode.com > stats 源码程序 matlab案例代码 > stats/EstimateOutofBagQuantileRegressionErrorExample.m
%% Estimate Out-of-Bag Quantile Regression Error %% % Load the |carsmall| data set. Consider a model that predicts the fuel % economy of a car given its engine displacement, weight, and number of % cylinders. Consider |Cylinders| a categorical variable. load carsmall Cylinders = categorical(Cylinders); X = table(Displacement,Weight,Cylinders,MPG); %% % Train an ensemble of bagged regression trees using the entire data set. % Specify 100 weak learners and save the out-of-bag indices. rng(1); % For reproducibility Mdl = TreeBagger(100,X,'MPG','Method','regression','OOBPrediction','on'); %% % |Mdl| is a |TreeBagger| ensemble. %% % Perform quantile regression, and out-of-bag estimate the MAD of the % entire ensemble using the predicted conditional medians. oobErr = oobQuantileError(Mdl) %% % |oobErr| is an unbiased estimate of the quantile regression error for the % entire ensemble.