Last answered:

08 May 2020

Posted on:

08 May 2020

0

Logistic Regression on purchase incidence vs average candy price

I am going through the Customer Analystic section. In this section, logistic regression is conduted to fit the model with our X or price and our Y or incidence.

The codes provided by the course are as follow:
""
# We create a Logistic Regression model using sk learn. Then we fit the model with our X or price and our Y or incidence.
model_purchase = LogisticRegression(solver = 'sag')
model_purchase.fit(X, Y)
""
I  try to do scatter plot on X,Y to see what happen. My codes following the above codes are
""
f=plt.figure(figsize=(16,8))
ax=f.add_subplot(111)
ax.scatter(X,Y)
**
However, I found that plot is not like a sigmoid function as we commonly have in Logistic Regression. ( it looks like a pair of parrell lines)
Confused.. is my scatter plot making sense here? do we expect to see a sigmoid-like scatter plot?

Many thanks!!

1 answers ( 0 marked as helpful)
Instructor
Posted on:

08 May 2020

0
    Hi MinliYu,  thanks for reaching out! When you create a scatter plot on X and Y, you're creating a scatter plot on those two variables X and Y. In our case: Y is the incidence column which is binary(contains 0s and 1s) X is the average price. A scatter plot shows each point with coordinates X and Y on a 2D plane.So, the pair of parallel lines you're seeing are for the 0s and 1s from the X variable. And a scatter plot of X and Y should look exactly like that.  A sigmoid function, on the other hand, is something different. The sigmoid function is the logistic function used by the Logistic Regression to estimate the class probabilities.    Best,  Eli  

Submit an answer