Cross validate function
vals = kfoldfun(obj,fun)
cross validates the function vals
= kfoldfun(obj
,fun
)fun
by applying fun
to
the data stored in the cross-validated model obj
.
You must pass fun
as a function handle.
|
Object of class |
|
A function handle for a cross-validation function. testvals = fun(CMP,Xtrain,Ytrain,Wtrain,Xtest,Ytest,Wtest)
|
|
The arrays of |
Cross validate a regression tree, and obtain the mean squared
error (see kfoldLoss
):
load imports-85 t = fitrtree(X(:,[4 5]),X(:,16),... 'predictornames',{'length' 'width'},... 'responsename','price'); cv = crossval(t); L = kfoldLoss(cv) L = 1.5489e+007
Examine the result of simple averaging of responses instead of using predictions:
f = @(cmp,Xtrain,Ytrain,Wtrain,Xtest,Ytest,Wtest)... mean((Ytest-mean(Ytrain)).^2) mean(kfoldfun(cv,f)) ans = 6.3497e+007
crossval
| fitrtree
| kfoldLoss
| kfoldPredict
| RegressionPartitionedEnsemble
| RegressionPartitionedModel