Question
Hi Everyone, I have a problem with classification. I have 39 samples of training data (39x10935) and 347 samples of testing data (347x10935). classify function returns: "The covariance matrix of each group in TRAINING must be positive definite" error. Is there any method to compute the minimal size of training set? I know that I could just add some test samples to the training set, but the nature of the problem that I am solving requires as little training samples as possible.
Related Questions
Expert Answer
John Williams
PhD Expert
Answered Nov 20, 2025
I understand that you may need as few training samples as possible. However, this is not always good, since your performance will not be so good (obviously).
If you really need to do so, I recommend you to use MATLAB's CVPARTITION. Choose 'holdout' method and try with different proportions until you find the minimum one. For example:
% Assuming you have a vector with the labels in an array called "classes" and your data (features) in a matrix called "myData". for ii = 1:19; testProportion = (ii*5)/100; c = cvpartition(classes, 'holdout',testProportion); trainData = myData(training(c,1),:); testData = myData(test(c,1),:); % Try your classifier here. end
Have a different question? Ask here