How to make matrix a possitive definite

8 ビュー (過去 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 Center および File ExchangeGet Started with Statistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by