scikit-learn/scikit-learn — Issue #614: KernelPCA with fit_inverse_transform=True doesn't support precomputed kernels
Author: bwhite
Created: 2012-02-09 07:27:10+00:00
State: open

The following happens when I try to use a precomputed kernel with kernelpca and fit_inverse_transform=True. It looks like this case isn't handled in the code but I haven't had a chance to patch it yet.

Traceback (most recent call last):
File "", line 37, in
File "/usr/local/lib/python2.7/site-packages/scikit_learn-0.10-py2.7-linux-i686.egg/sklearn/decomposition/kernel_pca.py", line 212, in fit_transform
self.fit(X, **params)
File "/usr/local/lib/python2.7/site-packages/scikit_learn-0.10-py2.7-linux-i686.egg/sklearn/decomposition/kernel_pca.py", line 195, in fit
self._fit_inverse_transform(X_transformed, X)
File "/usr/local/lib/python2.7/site-packages/scikit_learn-0.10-py2.7-linux-i686.egg/sklearn/decomposition/kernel_pca.py", line 173, in _fit_inverse_transfor\
m
self.dual_coef_ = linalg.solve(K, X, sym_pos=True, overwrite_a=True)
File "/usr/local/lib/python2.7/site-packages/scipy-0.10.0-py2.7-linux-i686.egg/scipy/linalg/basic.py", line 47, in solve
raise ValueError('expected square matrix')
ValueError: expected square matrix