Code covered by the BSD License

# A road to classification in high dimensional space: the regularized optimal affine discriminant

### Yang Feng (view profile)

A powerful method for binary classification in high dimensional space

analyzeReal(traindata, testdata)
```function [sROAD1fit, sROAD2fit, ROADfit] = analyzeReal(traindata, testdata)

%%%%traindata: ntrain*(p+1) matrix, last column class labels ,0 and 1
%%%%testdata: ntest*(p+1) matrix, last column class labels ,0 and 1
data = [traindata ;testdata];
trlab = traindata(:,end);
telab = testdata(:,end);
data = data(:,1:(end-1));
n1Train = sum(trlab==0);
n2Train = sum(trlab==1);
n1Test = sum(telab==0);
n2Test = sum(telab==1);
if(n1Train+n2Train+n1Test+n2Test~=size(data,1))
error('The labeling has problem, must be 0 for the first class and 1 for the second class');
end

[n p] = size(data);
dataMean = mean(data,2);
dataStd = std(data,0,2);

normData = (data-repmat(dataMean,1,p))./repmat(dataStd,1,p);

nTrain = n1Train + n2Train;
nTest = n1Test + n2Test;

Y1Train = normData(1:n1Train,:);
Y2Train = normData((n1Train+1):nTrain, :);

Y1Test = normData((nTrain+1):(nTrain+n1Test),:);
Y2Test = normData((n-n2Test+1):n,:);

x = [Y1Train;Y2Train];

y = [zeros(n1Train,1);ones(n2Train,1)];

xtest = [Y1Test;Y2Test];
ytest = [zeros(n1Test,1);ones(n2Test,1)];

para.epsilon=1e-4;
para.K=200;
para.alpha=0;
para.nfold=5;