Crossval and - how does crossval works?

2 views (last 30 days)
Hey!:) I am using in order to do build a decision tree for my data. If I want it to do cross validation automatic I have to include (‘crossval’,’on’), right? I have done it, but I am not quite sure what matlab has done exactly? What does KFold 10 means? How does this automatic crossvalidation works?
Thanks a lot for your help!
Please find my code below: >>,price,'crossval', 'on' )
rtree =
CrossValidatedModel: 'Tree'
PredictorNames: {'x1' 'x2' 'x3'}
CategoricalPredictors: []
ResponseName: 'Y'
NObservations: 5255
KFold: 10
Partition: [1x1 cvpartition]
ResponseTransform: 'none'

Accepted Answer

Shashank Prasanna
Shashank Prasanna on 30 Jun 2014
Edited: Shashank Prasanna on 30 Jun 2014
What does KFold 10 means?
matlab has done exactly?
MATLAB has performed kfold cross-validation and returned a partitioned model instead of a single regression tree. Crossvalidation allows you to assess the predictive performance of model on cross-validated data. You can access these methods using the output of a cross validated model: kfoldfun, kfoldLoss, kfoldPredict.
Alternatively you can fit a model and then call cross val this way:
rtree =,price);
rcrossvaltree = crossval(rtree);
Read more here (also includes examples):

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!