Skip to content
Advertisement

Sklearn logistic regression, plotting probability curve graph

I’m trying to create a logistic regression similar to the ISLR’s example, but using python instead

JavaScript

But I keep getting the graph on the left, when I want the one on the right:

enter image description here

Edit: plt.scatter(x,LogR.predict(x)) was my second, and also wrong guess.

Advertisement

Answer

you use predict(X) which gives out the prediction of the class. replace predict(X) with predict_proba(X)[:,1] which would gives out the probability of which the data belong to class 1.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement