Coding Linear Regression
To 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: during the training phase, the program approximates the data with a function; then, during the prediction phase, it uses the function to infer the number of pizzas.
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 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 ...
Get Programming Machine Learning now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.