Neural Networks Warehouse
Artificial Intelligence Depot
"As knowledge increases, ignorance unfolds." -Kennedy
KNOWLEDGE MESSAGES SUBMIT SEARCH  
I need Matlab surce code for five fold cross-validation for evaluation!!!please help!!!
I need help!! could some one please give me source code for 5 fold cross-validation ..i have two class with each class have 171 input (171 rows 10 column half for traning half for testing)
 
• I need Matlab surce code for five fold cross-validation for evaluation!!!please help!!!

I need urgent help!! could someone please give me source code for 5 fold cross-validation in MatLab. I have two class..class 1 and class 2 with each class have around 171 input (171 rows 10 column .half for traning half for testing).I need to do cross vaildation in order to get overall acurracy,overall precision and recall.

2 posts.
Saturday 01 May, 02:07
Reply
• 5-Fold Cross-Validation

Do you understand how k-fold cross-validation works?

Split the data 'k' ways- if the observations are in matrix rows. It is easy in MATLAB to randomly assign rows to 1 of 'k' groups, using 'rand'.

Then, rotate through all 'k' groups, each time building a model on everyone except group 'k', and test group 'k'. In MATLAB, use something like:

for i = 1:k,
% Train on:
DATA(find(GROUP ~= i),:)

% Test on:
DATA(find(GROUP == i),:)
end

At the end, aggregate test results and summarize.

-Predictor
http://will.dwinnell.com

249 posts.
Saturday 01 May, 04:36
Reply
• Thank you for your reply!! I still dont know how !!

Thank you Sir for advice!!
Actually I am very new to matlab neural network tool box i do know a bit how cross validations work but I don’t know how to implement .my problem is that I have two classes with some set data for training and testing I have to use either RBF or MPL neural mode with one hidden layer and i need to use 5-fold cross validation. therefore I don’t know how to start or implement.

2 posts.
Saturday 01 May, 10:55
Reply
• This is a code for 10-fold cross validation

And I think it can help you

function [TrainSet TestSet] = tfCV(A, i_th)

rows = size(A,1);
sizeG = round(rows/10); % size for each group. But the last group can be more or less

if i_th < 10
TrainSet = [A(1:(i_th-1) * sizeG,:); A(1+(i_th * sizeG):end,:)];
TestSet = A((1+(i_th-1) * sizeG):(i_th * sizeG),:);
else
TrainSet = A(1:(i_th-1) * sizeG,:);
TestSet = A((1+(i_th-1) * sizeG):end,:);
end

1 posts.
Wednesday 08 November, 00:15
Reply