load spect
Ytr   = 2*Ytr - 1;
Ytest = 2*Ytest - 1;

n = length(Ytr);
i = randperm(n);
Xtr = Xtr(i,:);
Ytr = Ytr(i);

folds = 10;
n_cv  = floor(n/folds);

a = 0;
for i = 1:folds
    % X_te: i-th block
    ite = n_cv*(i-1)+1:n_cv*i;
    % X_tr: all data except i-th block
    itr = [1:n_cv*(i-1) n_cv*i+1:n];
    
    w = learnRegERM(Xtr(itr,:), Ytr(itr), 10, @hinge, @omega2);
    
    f = Xtr(ite,:)*w;
    a = a + auc_roc(f, Ytr(ite))/folds;
end
w = learnRegERM(Xtr, Ytr, 10, @hinge, @omega2);

% AUC with cross validation (pessimistic estimator)
auc_cv = a
% AUC of training data (optimistic estimator)y1
auc_tr = auc_roc(Xtr*w, Ytr)
% AUC of test data (true - but in practice unknown - value)
auc_te = auc_roc(Xtest*w, Ytest, 1)
