Valueerror: Array Contains Nan Or Infinity In _assert_all_finite During Linearsvc
I was trying to classify the wine data set here -http://archive.ics.uci.edu/ml/datasets/Wine+Quality using logistic regression (with method ='bfgs' and l1 norm) and caught a singul
Solution 1:
This worked. The only I had to really change was use x_test*.values* along with the rest of pandas Dataframes(x_train, y_train, y_test) . As pointed out the only reason was incompatibility between pandas df and scikit-learn(which uses numpy arrays)
#changing your Pandas Dataframe elegantly to work with scikit-learn by transformation to numpy arrays>>> type(x_test)
<class'pandas.core.frame.DataFrame'>
>>> type(x_test.values)
<type'numpy.ndarray'>
This hack comes from this post http://python.dzone.com/articles/python-making-scikit-learn-and and @AndreasMueller - who pointed out the inconsistency.
Post a Comment for "Valueerror: Array Contains Nan Or Infinity In _assert_all_finite During Linearsvc"