Regression

Quick Reference

Core Concept

Predict continuous numerical values (not categories). Like estimating house price ($450,000) instead of classifying as "Expensive" or "Cheap".

Linear Regression

Find the line (or hyperplane) that best fits the data points.

Goal: Minimize distance between predictions and actual values.

The Model

h(x) = θᵀx + θ₀

Components:

Cost Function: Mean Squared Error (MSE)

J(θ) = (1/2n) * Σ (h(x⁽ⁱ⁾) - y⁽ⁱ⁾)²

Why square errors?

Finding Optimal Parameters

Analytical Solution (OLS)

Gradient Descent

Practical Considerations

Feature Scaling

Problem: Features with different ranges (bedrooms: 1-5, square footage: 500-5000) cause issues. Solution: Scale all features to similar range (e.g., 0 to 1). Benefit: Faster and more accurate convergence.

Outliers

Issue: Squared errors mean single outlier can drag entire line. Action: Always check for and handle anomalies before training.

Evaluation Metric: R-Squared

Meaning: Proportion of variance in target explained by model. Range: 0.0 to 1.0

Regression vs. Classification

Regression: Predicts quantity (temperature: 72.5°F) Classification: Predicts category (weather: Sunny/Rainy) Rule: If output is a number, use regression.

Quick Facts

← Previous: Features 📖 Read Deep Dive Next: Optimization →