machine learning – Python – Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19

machine learning – Python – Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19

You are not getting an error, its a warning. The prediction will still be printed right after the warning message.

The solution is listed in the warning as well:

Reshape your data either using X.reshape(-1, 1) if your data has a
single feature or X.reshape(1, -1) if it contains a single sample.

Which gets rid of the warning as promised:

>> print(clf.predict(np.array([10,10]).reshape(1,-1)))
[1]

machine learning – Python – Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19

Leave a Reply

Your email address will not be published. Required fields are marked *