function [Model, CVstats] = PROCEDURE_SplitApprTrain_GetCVROC(objstr)
%function PROCEDURE_SplitApprTrain_GetCVROC(objstr)
%
%intent: load the appearance training data from the disk.  Split it into training and test data.
%        build an SVM linear model, and get CV results.  Save the Model and CVresults

HelpTextInfo = help('PROCEDURE_SplitApprTrain_GetCVROC');
traindatafilename = sprintf('SobelAppearanceTrainData5_%s',objstr);
load(traindatafilename)%-> X,y,resolution,N,HelpTextInfo

n_examps = size(X,2);
p = randperm(n_examps);
pTrain = p(1:floor(n_examps /2));
pTest = p((floor(n_examps /2) + 1):end);
X_Train = X(:,pTrain);
y_Train = y(pTrain);
X_Test = X(:,pTest);
y_Test = y(pTest);
Model = CLSosusvm(X_Train,y_Train);
[yempl,yemp] = CLSosusvmC(X_Test,Model);
CVstats = ROCetc(yemp,y_Test);
save(sprintf('ApprModel_N_CVstats5_%s.mat',objstr),'pTrain','Model','CVstats','HelpTextInfo','traindatafilename','yemp');



