python - sklearn PCA producing numpy.linalg.linalg.LinAlgError -
i wanted run pca on matrix, got numpy.linalg.linalg.linalgerror. attached matrix , code.
get matrix here: http://workupload.com/file/yvsvhgja
import numpy np sklearn.decomposition import pca matrix = np.load("matrix.npy") transformed = pca(n_components=3).fit_transform(matrix)
here full stack trace, think can reproduce it.
traceback (most recent call last): file "<stdin>", line 1, in <module> file "/home/user/anaconda/lib/python2.7/site-packages/sklearn/decomposition/pca.py", line 242, in fit_transform u, s, v = self._fit(x) file "/home/user/anaconda/lib/python2.7/site-packages/sklearn/decomposition/pca.py", line 275, in _fit u, s, v = linalg.svd(x, full_matrices=false) file "/home/user/anaconda/lib/python2.7/site-packages/scipy/linalg/decomp_svd.py", line 109, in svd raise linalgerror("svd did not converge") numpy.linalg.linalg.linalgerror: svd did not converge
any appreciated.
ps:
np.__version__ '1.9.2' sklearn.__version__ '0.15.2'
pps: running linux
it works on macs, guess doesn't much.
try x[:,:100]
:1000 ?
there lapack tests svd; daunting.
"tell me lapack installation" command useful, don't see offhand.
from __future__ import division import platform import sys import numpy np numpy.distutils.system_info import get_info np.set_printoptions( threshold=100, edgeitems=10, linewidth=80, formatter = dict( float = lambda x: "%.2g" % x )) # float arrays %.2g def versions(): print "versions: numpy %s python %s " % ( np.__version__, sys.version.split()[0] ) if platform.system() == "darwin": print "mac %s" % platform.mac_ver()[0] else: print platform.platform( terse=1 ) # ? info in "blas_opt lapack_opt " .split(): print "%s: %s" % (info, get_info( info, 0 )) print "" versions() #............................................................................... x = np.load( "matrix.npy" ) print "x:", x.shape, np.percentile( x, q=[0,25,50,75,100] ) u, sing, vt = np.linalg.svd( x, full_matrices=false ) print "np.linalg.svd: x %s -> u %s sing %s vt %s" % ( x.shape, u.shape, sing.shape, vt.shape ) print "svd sing:", sing
versions: numpy 1.9.2 python 2.7.6 mac 10.8.3 blas_opt: {'extra_link_args': ['-wl,-framework', '-wl,accelerate'], 'extra_compile_args': ['-msse3', '-dapple_accelerate_sgemv_patch', '-i/system/library/frameworks/veclib.framework/headers'], 'define_macros': [('no_atlas_info', 3)]} lapack_opt: {'extra_link_args': ['-wl,-framework', '-wl,accelerate'], 'extra_compile_args': ['-msse3', '-dapple_accelerate_sgemv_patch'], 'define_macros': [('no_atlas_info', 3)]} x: (384, 5000) [-4.4e+02 -20 -0.27 17 4.5e+02] np.linalg.svd: x (384, 5000) -> u (384, 384) sing (384,) vt (384, 5000) svd sing: [5e+04 2.3e+04 2.1e+04 1.3e+04 1.2e+04 1.1e+04 1.1e+04 4.3e+03 3.3e+03 1.8e+03 ..., 0.00014 0.00014 0.00013 0.00013 0.00011 5.3e-12 5.3e-12 5.1e-16 1.3e-16 3.3e-17]
Comments
Post a Comment