function [correlation]=ridgeCV(savePath,EEG,k,ridgeParams)
    load(savePath);
    clear classification;
    if EEG
        trainingData=trainingDataEEG;
    else
        trainingData=trainingDataEMG;
    end
    clear trainingDataEEG;
    clear trainingDataEMG;
    
    correlation=zeros(size(kinematics,2),1);
    
    for j=1:size(kinematics,2)
        randMap=randperm(size(trainingData,1));
        kin=kinematics(:,j);
        correlations=zeros([k,1]);

        parfor i=1:k
            leaveData=trainingData(mod(randMap,k)==i-1,:);
            leaveKin=kin(mod(randMap,k)==i-1);
            remainingData=trainingData(mod(randMap,k)~=i-1,:);
            remainingKin=kin(mod(randMap,k)~=i-1);
            %fprintf('%s create %ith model\n',datestr(datetime('now')),i)

            [coeffs]=kFoldRidge(remainingData,remainingKin,k,ridgeParams);

            correlations(i)=ridgeCorrelation(leaveData,leaveKin,coeffs);
        end

        correlation(j)=mean(correlations);
    end
end