classifier's performance

1 view (last 30 days)
Alessandro Napoli
Alessandro Napoli on 8 Mar 2018
Edited: Alessandro Napoli on 8 Mar 2018
Hi,
I have been using the Classification Learner app for the past week to train classifiers on a few sets of features (training data set). Everything was fine with the app, but the performance of the extracted features weren't optimal, so I have decided to go back to the drawing board and improve my feature extraction. I'm now running a parametric feature extraction that I want to eventually test with a series of classifiers. To automate the whole process I'm training the classifiers and assessing their performance using Matlab functions, instead of the Classifier App (GUI). The issue is that when using Matlab code to assess performance I get this error:
Error using classify (line 229) The pooled covariance matrix of TRAINING must be positive definite.
Here is the simple code:
load('classify_this.mat');
responses = dat_HS(:,end);
x = dat_HS(:,1:end-1);
kfold = 3;
indices = crossvalind('Kfold',responses,kfold);
tree = fitctree(x,responses,'MaxNumSplits',4,'CrossVal','on','kfold',kfold);
cp = classperf(responses);
for i = 1:kfold
test = (indices == i); train = ~test;
class = classify(x(test,:),x(train,:),responses(train));
% updates the CP object with the current classification results
classperf(cp,class,test)
end
cp.CorrectRate % queries for the correct classification rate
Again I'm using the same parameters and cross-validation values that I have been using with the Classifier App. I think I understand why I'm getting this error, what I don't understand is why I don't get the same error when suing the Classification Learner App. I have attached a sample data set in which the last column is the training labels just in case you want to try to replicate the problem.
Thanks a lot

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!