Phase 02: ML Fundamentals

Linear Regression

Linear regression draws the best straight line through your data. It is the "hello world" of machine learning. Derive the gradient descent update rules for mean squared error and implement linear regression from scratch. Compare gradient descent and the normal equation in terms of computational complexity and when to use each. Build a multiple linear regression model with feature standardization and interpret the learned weights. Explain how Ridge regression (L2 regularization) prevents overfitting by penalizing large weights. You have data: house sizes and their sale prices. You want to predict the price of a new house given its size. You could eyeball it on a scatter plot, but you need a formula. You need a line that best fits the data so you can plug in any size and get a price prediction. Linear regression gives you that line. More importantly, it introduces the entire ML training loop: define a model, define a cost function, optimize the parameters. Every ML algorithm follows this same pattern. Master it here with the simplest case, and you will recognize it everywhere. This is not just for simple problems. Linear regression is used in production systems for demand forecasting, A/B test analysis, financial modeling, and as a baseline for every regression task. Linear regression assumes a linear relationship between input (x) and output (y):…

Linear regression draws the best straight line through your data. It is the "hello world" of machine learning. Derive the gradient descent update rules for…

This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.

Browse the complete course catalog or open this lesson on GitHub.