Hey everyone

Classroom Item: Week 3, Optional lab: Sigmoid function & logistic regression

I wanted to ask something in this lab that I didn’t quite catch, in the instructions below, it says that the orange line “z” does **not** match a linear regression line. How so when z = w.x + b ??

- Click on ‘Run Logistic Regression’ to find the best logistic regression model for the given training data
- Note the resulting model fits the data quite well. The orange line is ‘𝑧z’ or 𝐰⋅𝐱(𝑖)+𝑏w⋅x(i)+b above.
**It does not match the line in a linear regression model**. Further improve these results by applying a *threshold*.

Hi Ahmed Abdelhaleem, welcome to the community!

The main difference between logistic and linear regression is in the interpretation of the output. While both models have the same form for their decision boundary (i.e., z = w \cdot x + b ) they differ in their objective.

In **linear regression**, the output z is used directly as the predicted value. The goal is to find a linear relationship between the input features and the continuous output values.

In **logistic regression**, on the other hand, the output z = w \cdot x + b is passed through a **sigmoid function**, which squeezes z into a range between 0 and 1, representing probabilities. The goal here is classification, where we want to predict the probability of a certain class (e.g. 0 or 1). Therefore, the orange line representing z in logistic regression indicates a decision boundary, not a direct fit as in linear regression.

This is why z doesn’t fit the linear regression line - logistic regression doesn’t try to model the output directly. Instead, it models the probability through the sigmoid function applied to z .

Hope this helps!

2 Likes

Thank you @nadtriana, I now understand what he meant by that sentence.

1 Like