Calculating error or loss

There are many ways to calculate the error for ML algorithms, but in this chapter we will be using one of the most popular techniques: sum of squared distance error. Now we are going straight into details.

What does this error function do for us? Recall our goal: we want to get the line of best fit for our dataset. Refer to Figure 9.19, which is the equation of line slope. Here, m is the slope of line, b is the y intercept, x and y are the data points--in our case, x is the numbers of hours the student studies and y is the test score. Refer to Figure 9.19:

Figure 9.19: Line slope equation (Image credit: https://www.tes.com/lessons/Xn3MVjd8CqjH-Q/y-mx-b) ...

Get Python Natural Language Processing 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.