# cross validation for small dataset

I have a dataset of 39 medical MR images, and I have to build a model to classify the tumor type. so is it suitable to use k-fold cross validation for validating the model? if so, what would be the number of K?

• LOOCV (k=1) is best given your data. – user2974951 Dec 5 '18 at 14:00
• thank you sir for your quick reply, so it is not recomended to use k-fold cross validation? – gin Dec 5 '18 at 14:12
• LOOCV is a type of CV when k=n (not k=1 as in my previous comment), so they are similar, but LOOCV will be better in this case since you have a very small dataset and k-fold CV will partion it even further into smaller datasets. – user2974951 Dec 5 '18 at 14:19
• you mean by n is the data samples? in my case 39? – gin Dec 5 '18 at 15:39
• Yes, n is sample size. – user2974951 Dec 6 '18 at 6:30

Given the size of your data set, the best approach to cross validation is the Leave-One-Out method. You haven't discussed the language or package you used for your model, but generally speaking you set the $$k$$ equal to the number of records. In your case, that 39. This will cause your model to train on 38 instances and predict the 39th, with each instance eventually will receive a classification.
• I am not sure about MATLAB, but if it has a generic Cross Validation function, you should probably set $k=39$. – Skiddles Dec 5 '18 at 14:15
• Did that work for you? I have found that sometimes the measures get out of whack with LOO. It could have been user error, but I just didn't have time to work through it so changed $k$ to something smaller. Of course, as the number of instances increases, using LOO takes a lot longer to complete and it is questionable if a smaller $k$ is any less valuable overall. You really wouldn't want to try LOO with a sizable data set. – Skiddles Dec 5 '18 at 15:13
• Sorry to give you mixed messages. Since your data set is so small, I would set $k=39$ because it will give the model the most data to train with (38 records). If you had 100,000 records, I'd probably set $k=5$ depending on the type of model you are developing. Does that make sense? – Skiddles Dec 5 '18 at 15:45