Coding Linear Regression
Learn how to apply linear regression by getting a bird's eye view of the complete hierarchy.
We'll cover the following
Let’s recap our goal. We want to write a program that calculates the number of pizzas from the number of reservations. That program should follow the approach we discussed in The Math Behind the Magic: the program approximates the data with a function during the training phase. Then, during the prediction phase, it uses the function to infer the number of pizzas.
Linear regression in practice
In the general case, finding a function that approximates the data can be a lot of work. In our specific case, however, we lucked out. Our data points are roughly aligned, so that we can approximate them with an especially simple function: a line.
Let’s see what that line would look like. For now, let’s pick a line that passes by the origin of the axes, as shown in the following chart, because that will make things easier, to begin with:
Get hands-on with 1200+ tech skills courses.