K-Fold Cross Validation

3 views (last 30 days)
neamah al-naffakh
neamah al-naffakh on 25 Jan 2017
Commented: Swaroop Mishra on 31 Jan 2017
Hi Guys,
I have data of 36 users
as shown in the code (MATLAB) data is loaded into a matrix called Feat_Vec1
clear;
for nc = 1 : 36 % nc number of users
% Load data into MATLAB
data{nc} = load( sprintf('U%02d_Acc_TimeD_FreqD_FDay.mat', nc) );
% assign data into Matrix
Feat_Vec1{nc} = data{nc}.Acc_TD_Feat_Vec(:,:);
end
for each user, I have 36 rows and 143 columns as a result, Feat_Vec1 contains 36 cells (number of users) and each cell contains 36 rows and 143 columns
I'd like to use 9-Fold Cross Validation in order to divide my dataset into training and testing.
First of all, 9-fold cross-validation means to user 8/9-th data for training and 1/9-th for testing. Repeat this nine times
I have seen this the documentation in MATLAB help but don't understand it!
I'm wondering if someone could help me please with the coding of 9-Fold Cross Validation for each user?
for examples:
for user1, 4 values from each column will be stored for testing and 32 values of each column will be used to train his model. This procedure will be repeated 9 times
Really appreciate any help
Regards.
  2 Comments
John Chilleri
John Chilleri on 26 Jan 2017
Hello,
What metric are you using?
K-Fold cross validation is pretty easy to code yourself, but what model are you fitting to the data (linear/quadratic/etc.)? And how would you like the testing set to be tested, perhaps the standard MSE?
Swaroop Mishra
Swaroop Mishra on 31 Jan 2017
Additionally, to reduce the coding effort, you can use Classification Learner App which is a part of Statistics and Machine Learning Toolbox.
In the Classification Learner App, you can select Data and Validation for Classification Problem

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!