pyrcca
pyrcca copied to clipboard
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.
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?
I also tried eliminating the all-zeros columns but that didn't help
Try to add some regularisation instead of setting it to 0
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?