Middle — Senior
What is the difference between linear and logistic regression?
sobes.tech AI
Answer from AI
Linear and logistic regressions are machine learning methods for solving different tasks:
-
Linear regression is used for predicting continuous numerical values. The model builds a linear dependence between input features and the target variable.
-
Logistic regression is applied to classification tasks, usually binary. It estimates the probability of an object belonging to one of the classes, using a logistic function (sigmoid) to transform a linear combination of features into a probability from 0 to 1.
Example:
- Linear regression: predicting the price of a house based on area and number of rooms.
- Logistic regression: determining whether an email is spam (yes/no).
The main difference lies in the target variable and activation function:
| Characteristic | Linear Regression | Logistic Regression |
|---|---|---|
| Task type | Regression (number) | Classification (class labels) |
| Target variable | Continuous | Discrete (usually 0 or 1) |
| Activation function | Linear | Logistic (sigmoid) |
| Model output | Any number | Probability (0..1) |