Notes

Linear Regression

When you want to predict a number—like a house price or next week’s demand—you usually start by asking a simple question: “If I change this input a little, how much does the output change?” Linear regression is the classic model built around that idea.

What it is and what it learns

Linear regression predicts a continuous target by combining features with learned weights:

ŷ = b0 + b1 x1 + b2 x2 + ... + bp xp

Each coefficient (like b1) represents the expected change in the prediction when that feature increases by 1 unit, holding other features fixed. The intercept b0 is the baseline prediction when all features are zero. Despite the name, it can model curved relationships if you include transformed features (e.g., x², log(x)).

How it’s fit: least squares intuition

The most common version, ordinary least squares (OLS), chooses coefficients that minimize the sum of squared errors between true values and predictions. Squaring makes large mistakes count a lot, which strongly influences the fitted line/plane. In practice, you’ll see this in scikit-learn as:

from sklearn.linear_model import LinearRegression
model = LinearRegression().fit(X, y)

Why it matters in real pipelines

  • Baseline and interpretability: Great first model for problems like house price prediction, credit loss estimation, or demand forecasting because coefficients are easy to explain.
  • Assumptions and failure modes: Outliers can distort OLS; correlated features can make coefficients unstable; non-constant noise (heteroscedasticity) can mislead uncertainty estimates.
  • Regularized variants: Ridge and Lasso add penalties to control overfitting and handle many features.

Linear Regression is a supervised regression method that models a continuous target as a weighted linear combination of input features (e.g., predicting house price from size and location indicators). Parameters are typically fit by minimizing squared prediction error, with variants such as ordinary least squares, ridge, and lasso. It matters because it provides a fast, interpretable baseline for prediction and feature effect estimation, and underpins many evaluation and regularization concepts.

Think of Linear Regression like drawing the best “trend line” through a scatter of points on a chart. If you plot house size on the bottom and house price on the side, the line helps you guess the price of a new house based on its size.

In AI, Linear Regression is a simple way to predict a number (not a category) from examples where you already know the right answers. It learns how different clues—like square footage, location, and number of bedrooms—push the prediction up or down. It’s popular because it’s fast, easy to understand, and often a strong baseline for forecasting.