How to make matrix a possitive definite
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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
0 个评论
更多回答(2 个)
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
0 个评论
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'
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Classification Ensembles 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!