How to make matrix a possitive definite

조회 수: 4 (최근 30일)
Micha? Kowalczyk
Micha? Kowalczyk 2011년 8월 24일
답변: Fadi Alsuhimat 2020년 7월 6일
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

채택된 답변

Arturo Moncada-Torres
Arturo Moncada-Torres 2011년 8월 24일
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.

추가 답변 (2개)

Ilya
Ilya 2011년 8월 25일
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 2020년 7월 6일
Just write it like this
augmentedTrainset=augmentedImageDatastore(imagesize,...
trainset,'ColorPreprocessing','gray2rgb');
%%% this mean you add another type for lda by using 'ColorPreprocessing','gray2rgb'

카테고리

Help CenterFile Exchange에서 Classification Ensembles에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by