How to make matrix a possitive definite

Illustration
Saishasingh - 2020-07-20T13:10:11+00:00
Question: How to make matrix a possitive definite

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.

Expert Answer

Profile picture of John Williams John Williams answered . 2025-11-20

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


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!