Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LinAlgError: the leading minor of order 299 of 'b' is not positive definite. The factorization of ' b' could not be completed and no eigenvalues or eigenvectors were computed. #15

Open
Char-Aznable opened this issue Oct 15, 2019 · 3 comments
Labels

Comments

@Char-Aznable
Copy link

Hi, I am trying to perform CCA on my 2 data sets, both of which are of shape 6030 samples by 499 features. I am using

cca = rcca.CCA(kernelcca = False, reg = 0., numCC = nCCA)
cca.train([x1, x2])

and get this error:

Training CCA, kernel = None, regularization = 0.0000, 3 components                                 
---------------------------------------------------------------------------                        
LinAlgError                               Traceback (most recent call last)                        
<ipython-input-144-4470a9a5f17c> in <module>
----> 1 cca.train([x1, x2])

/home/aznb/pyrcca/rcca.py in train(self, data)
    239 
    240     def train(self, data):
--> 241         return super(CCA, self).train(data)
    242 
    243 

/home/aznb/pyrcca/rcca.py in train(self, data)
     37         comps = kcca(data, self.reg, self.numCC, kernelcca=self.kernelcca,
     38                      ktype=self.ktype, gausigma=self.gausigma,
---> 39                      degree=self.degree)
     40         self.cancorrs, self.ws, self.comps = recon(data, comps,
     41                                                    kernelcca=self.kernelcca)

/home/aznb/pyrcca/rcca.py in kcca(data, reg, numCC, kernelcca, ktype, gausigma, degree)
    299 
    300     maxCC = LH.shape[0]
--> 301     r, Vs = eigh(LH, RH, eigvals=(maxCC - numCC, maxCC - 1))
    302     r[np.isnan(r)] = 0
    303     rindex = np.argsort(r)[::-1]

~/.linuxbrew/opt/python/lib/python3.7/site-packages/scipy/linalg/decomp.py in eigh(a, b, lower, eig
vals_only, overwrite_a, overwrite_b, turbo, eigvals, type, check_finite)
    491                           " factorization of 'b' could not be completed"
    492                           " and no eigenvalues or eigenvectors were"
--> 493                           " computed." % (info-b1.shape[0]))
    494 
    495 

LinAlgError: the leading minor of order 299 of 'b' is not positive definite. The factorization of '
b' could not be completed and no eigenvalues or eigenvectors were computed.

On the other hand, Scikit-learn's CCA does give results without error. Any clue where I should look into what happened?

@Char-Aznable
Copy link
Author

I also tried eliminating the all-zeros columns but that didn't help

@pinouche
Copy link

Try to add some regularisation instead of setting it to 0

@kavishgandhi
Copy link

I am facing a similar problem, I have 2 datasets of size 512x8 on which I am trying to do cca. can someone suggest to me what regularization and numCC I should use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants