function out = crossVal(bigK, label, data, params)

out = [];

[rows cols] = size(data);
randIndex = randperm(rows);

for i = 1:rows
    randData(i,:) = data(randIndex(i), :);
    randLabel(i,:) = label(randIndex(i), :);
end

partSize = floor(rows/bigK);

for k = 1:bigK
    %% build train and test sets
    trainData = randData;
    trainLabel = randLabel;
    
    start = (k-1)*partSize + 1;
    stop = k*partSize;
    
    if (k == bigK)
        stop = rows;
    end
    
    trainData(start:stop,:) = [];
    trainLabel(start:stop,:) = [];
    
    testData = randData(start:stop,:);
    testLabel = randLabel(start:stop,:);
    
    
    %% train the SVM
    model = svmtrain(trainLabel, trainData, params);
    
    %% test the SVM
    [predicted_label, accuracy, dec_values] = svmpredict(testLabel, testData, model, '');
    
    out = [out; accuracy(2)];
end
