Leave-One-​Out-Cross-​Validation

8 views (last 30 days)
Milena
Milena on 18 Oct 2022
Commented: Milena on 20 Oct 2022
Hi, I need to do a Leave-One-Out-Cross-Validation, but I dont even know how to start.
I read cvpartition etc.
Can someone help me please?
Thanks!
  5 Comments
Adam Danz
Adam Danz on 19 Oct 2022
It sounds like you have general quesitons about cross validation rather than how to perform cross validation in MATLAB.
As the example in the documentation explains, this line below applies the leave-one-out partition to the original data, X, and takes the mean of the training observations for each repetition by using crossval. The training observations are 9 of the 10 elements of the vector X and the test data is the single remaining element that was left out. This is repeated until each data point is left out of the training set. Therefore, values has 10 element and each element is the mean of 9 observations in X.
values = crossval(@(Xtrain,Xtest)mean(Xtrain),X,'Partition',c)
Milena
Milena on 20 Oct 2022
Thank you Adam, somehow I didnt understand it (maybe because of language barriers) but I have watched some videos now and it clicked. :)

Sign in to comment.

Answers (0)

Categories

Find more on Get Started with Statistics and Machine Learning Toolbox in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!