raise LinAlgError("SVD did not converge") LinAlgError: SVD did not converge in matplotlib pca determination

user 3317704 picture user 3317704 · Feb 17, 2014 · Viewed 73.5k times · Source

code :

import numpy
from matplotlib.mlab import PCA
file_name = "store1_pca_matrix.txt"
ori_data = numpy.loadtxt(file_name,dtype='float', comments='#', delimiter=None,                 converters=None, skiprows=0, usecols=None, unpack=False, ndmin=0)
result = PCA(ori_data)

this is my code. though my input matrix is devoid of the nan and inf, i do get the error stated below.

raise LinAlgError("SVD did not converge") LinAlgError: SVD did not converge

what's the problem?

Answer

jseabold picture jseabold · Mar 20, 2014

This can happen when there are inf or nan values in the data.

Use this to remove nan values:

ori_data.dropna(inplace=True)