How to make matrix a possitive definite

9 visualizzazioni (ultimi 30 giorni)
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.
Thank you in advance!
Michael

Risposta accettata

Arturo Moncada-Torres
Arturo Moncada-Torres il 24 Ago 2011
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
I suggest you to take a look at this FEX wonderful example of classification posted by Richard.

Più risposte (2)

Ilya
Ilya il 25 Ago 2011
If you have 10935 predictors, your entire training and test data are not going to be enough to make the covariance matrix non-singular. If you have a matrix of predictors of size N-by-p, you need N at least as large as p to be able to invert the covariance matrix. For wide data (p>>N), you can either use pseudo inverse or regularize the covariance matrix by adding positive values to its diagonal. Neither is available from CLASSIFY function.
In 11b release, you could use ClassificationDiscriminant.fit with 'pseudoLinear' or 'pseudoQuadratic' option.
-Ilya

Fadi Alsuhimat
Fadi Alsuhimat il 6 Lug 2020
Just write it like this
augmentedTrainset=augmentedImageDatastore(imagesize,...
trainset,'ColorPreprocessing','gray2rgb');
%%% this mean you add another type for lda by using 'ColorPreprocessing','gray2rgb'

Community Treasure Hunt

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

Start Hunting!

Translated by