Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

Deprecation warning in machine learning intro #2

Open
sahaia1 opened this issue Apr 30, 2016 · 2 comments
Open

Deprecation warning in machine learning intro #2

sahaia1 opened this issue Apr 30, 2016 · 2 comments

Comments

@sahaia1
Copy link

sahaia1 commented Apr 30, 2016

I am seeing a Deprecation Warning in code line number two where the "plot_sgd_separator()" function is called. The warning is as follows.

DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and willraise ValueError in 0.19. 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.

screenshot 2016-04-30 17 52 03

@pfrcks
Copy link

pfrcks commented Jul 4, 2016

@sahaia1 This is due to the error in line
p = clf.decision_function([x1, x2])

the decision_function gives this warning as it expects an input of the type [[]].
Just do what it says.
Store the x1, x2 values in a numpy array and reshape it using the reshape(1, -1)

Hope that helps

@robmarkcole
Copy link

robmarkcole commented Oct 24, 2017

The following fixed this issue, line 22 in sgd_seperator.py:

    for (i, j), val in np.ndenumerate(X1):
        x1 = val
        x2 = X2[i, j]

        x1 = np.array(x1)
        x2 = np.array(x2)
        x_tot = np.array([x1, x2])
        x_tot = x_tot.reshape(1, -1)
        p = clf.decision_function(x_tot)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants