DSPRelated.com
Forums

Hi All,
I have an audio recording (wav file) that is A seconds long, and it needs to be classified as [class_A] or [class_B].

After exploring Train and Cross Validate an SVM Classifier  and Cross-validated support vector machine classifier , This is my Matlab code (code 1) to calculate 10−fold misclassification rate (MCR) with SVM. I want to make sure it’s effectively computing the 10-fold MCR? What’s the difference with code 2 ?

X % my features vector, matrix of 2000x3000 (2000 training examples and 3000 features)
Y % vector of 2000*1 (class labels for the 2000 training examples) containing two classes 1 and -1


% Code 1
SVMModel = fitcsvm(X,Y,'Standardize',true);
CVSVMModel = crossval(SVMModel); %By default, crossval uses 10-fold cross validation.
classLoss = kfoldLoss(CVSVMModel); % MCR ?


% Code 2 (it’s not using SVM as classifier, it’s using discriminant analysis classification – LDA)
cp = cvpartition(Y,'k',10); % Stratified cross-validation
classf = @(XTRAIN, ytrain,XTEST)(classify(XTEST,XTRAIN,ytrain));
cvMCR = crossval('mcr',X),Y,'predfun',classf,'partition',cp);