- If your data is not stationary, then using stationary data (i.e. using differences instead of levels) could solve the problem.
- Check if some columns in your data are linearly dependent on each other.
- If the columns have different scales (for example one column consists of very small numbers, another columns has very large numbers), scale the columns so that the numbers are approximately of the same magnitude
classify and crossval function which bad with positive definite
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
1 I have a set of data (20 x 1200)(sample x variance) (1)the first colum of data is the group data [1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 ] thus the group 1 has 7 samples,group 2 has 8 samples, group 3 has 5 samples,
(2)the rest colum (2:end) is the specrta data.
2 (1)when I use classify function with tpye of linear,quadratic, mahalanobis in matlab 2012
It runs error as below:
its faults classify (line 277)
The covariance matrix of each group in TRAINING must be positive definite.
(2)when I use classify function with tpye of diaglinear (or diagquadratic )its OK
and then I make crossvalidation with code of:
cp = cvpartition(group,'leaveout');
ldaClassFun= @(xtrain,ytrain,xtest)(classify(xtest,xtrain,ytrain));
ldaCVErr = crossval('mcr',training,group,'predfun',ldaClassFun,'partition',cp)
It runs error as below:
its faults crossval>evalFun (line 480)
The function '@(xtrain,ytrain,xtest)(classify(xtest,xtrain,ytrain))' generated the following error:
The pooled covariance matrix of TRAINING must be positive definite.
its faults crossval>getLossVal (line 517)
funResult = evalFun(funorStr,arg(1:end-1));
its faults crossval (line 416)
[funResult,outarg] = getLossVal(i, nData, cvp, data, predfun);
So, did anyone know why and how to cope with them!!! Thanks very much!!!
0 commentaires
Réponses (1)
Roger Wohlwend
le 17 Oct 2014
Matlab demands a positive definite covariance matrix and in your case that requirement is obviously not met. What can you do?
0 commentaires
Voir également
Catégories
En savoir plus sur Resampling Techniques dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!