Linear & Logistic Regression
You'll learn to
- -Understand linear regression as fitting a straight-line relationship for numeric prediction
- -Understand logistic regression as linear regression adapted for classification
- -Derive and implement the closed-form least-squares solution for simple linear regression
Linear regression is often the very first ML algorithm anyone learns, and for good reason. It is simple, interpretable, and still genuinely useful in production for the right kind of problem.
Linear Regression: Fitting a Line (or Plane)
Given examples of inputs and a numeric output, linear regression finds the best-fitting straight-line relationship between them, or with multiple inputs, the best-fitting flat plane through higher-dimensional space. "Best-fitting" means the one that minimizes a loss function, usually squared error, across all the training examples.
The Closed-Form Solution
Unlike most ML models, simple linear regression does not need gradient descent at all. Minimizing squared error has an exact, closed-form answer you can compute directly from the data in one pass.
Logistic Regression: The Classification Cousin
Despite the name, logistic regression is used for classification, not regression. It takes the same underlying idea, a weighted combination of inputs, and squashes the result through the sigmoid function, which always outputs a number between 0 and 1 that reads as a probability.
- -Linear regression predicts a continuous number: price, temperature, delivery time.
- -Logistic regression predicts a probability, used for binary classification: churn or no churn, spam or not spam.
Both models are "linear" in the sense that they combine inputs by weighting and summing them, with no interactions or curves unless you explicitly engineer them in. That makes them fast, interpretable, and a strong first baseline, even when a more complex model eventually outperforms them.
Interview Signal is part of Pro
See a real weak answer next to a real strong one for this exact topic.
Quiz is part of Pro
Test what you just read with a short quiz, and bank the XP.