Predict response for observations not used for training.
yfit = kfoldPredict(obj)
yfit = kfoldPredict(obj) returns the predicted
values for the responses of the training data based on
an object trained on out-of-fold observations.
Object of class
A vector of predicted values for the response data based on a model trained on out-of-fold observations.
Construct a partitioned regression model, and examine the cross-validation
loss. The cross-validation loss is the mean squared error between
the true response data:
load carsmall XX = [Cylinders Displacement Horsepower Weight]; YY = MPG; tree = fitrtree(XX,YY); cvmodel = crossval(tree); L = kfoldLoss(cvmodel) L = 26.5271 yfit = kfoldPredict(cvmodel); mean( (yfit - tree.Y).^2 ) ans = 26.5271