python 2.7 - sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype('float64') -
im using sklearn , having problems affinity propagation, have built input matrix, , keep getting following error.
valueerror: input contains nan, infinity or value large dtype('float64'). i have run
np.isnan(mat.any()) #and gets false np.isfinite(mat.all()) #and gets true i tried using
mat[np.isfinite(mat) == true] = 0 to remove infinite values did not work either. can do rid of infinite values in matrix can use affinity propagation algorithm?
i using anaconda , python 2.7.9.
this might happen inside scikit, , depends on you're doing. recommend reading documentation functions you're using. might using 1 depends e.g. on matrix being positive definite , not fulfilling criteria.
edit: how miss that:
np.isnan(mat.any()) #and gets false np.isfinite(mat.all()) #and gets true is wrong. right be:
np.any(np.isnan(mat)) and
np.all(np.isfinite(mat)) you want check wheter of element nan, , not whether return value of any function number...
Comments
Post a Comment