clear all % Load the data and select features for classification load fisheriris; data = meas; %Get the size of the data N = size(data,1); % Extract the Setosa class groups_temp = ismember(species,'versicolor');%versicolor,virginica,setosa %convert the group to 1&-1 groups =2*groups_temp - ones(N,1); indices = crossvalind('Kfold', groups); ErrorMin =1; for r=1:1:5 for C=1:1:5 ErrorNum =0; for i=1:5 %Use K-fold to get train data and test data test = (indices == i); train =~test; traindata = data(train,:); traingroup = groups(train,:); trainlength = length(traingroup); testdata = data(test,:); testgroup = groups(test,:);