Alright, let's put our calculus tools to work. We've discussed finding minimums and maximums using derivatives and the idea of gradient descent. Now, we'll apply these ideas to a fundamental machine learning model: Simple Linear Regression.
The goal of simple linear regression is to find the best straight line that describes the relationship between a single input feature and a target output. Imagine you have some data points plotted on a graph. Linear regression tries to draw a line through these points that fits them as closely as possible.
The equation for a straight line is likely familiar:
y=mx+bLet's break down the components in a machine learning context:
In machine learning terminology, m and b are the parameters (or sometimes called weights or coefficients) of our model. Our objective during training is to find the optimal values for m and b that make our line fit the data best.
Consider a small dataset relating study hours (x) to exam scores (y).
The blue dots represent our data. The green dashed line seems to capture the trend reasonably well, while the red dotted line is clearly a poor fit. Linear regression aims to find the line parameters (m and b) that result in the best possible fit, like the green line or even better.
This process of finding the "best fit" line is a supervised learning task. We are given example pairs of (x,y) (study hours, exam score) and we want the machine learning algorithm to learn the relationship, represented by the parameters m and b. Once learned, we can use the model y=mx+b to predict the exam score for a new number of study hours.
The core idea is that we can measure how good a particular line (defined by specific values of m and b) fits the data. If we can measure this "goodness of fit" (or conversely, the "badness of fit" or error), we can then use calculus, specifically gradient descent, to systematically adjust m and b to make the line fit better and better.
This "measure of fit" is what we call a cost function, which we will define in the next section. Remember, for our optimization algorithms, m and b are the variables we will be adjusting to minimize this cost.
© 2025 ApX Machine Learning