Regression

In tasks where you have to predict real numbers or regression, many error measures are derived from Euclidean algebra:

  • Mean absolute error or MAE: This is the mean L1 norm of the difference vector between the predicted and real values:
In: from sklearn.metrics import mean_absolute_error     mean_absolute_error([1.0, 0.0, 0.0], [0.0, 0.0, -1.0])   Out: 0.66666666666666663
  • Mean squared error or MSE: This is the mean L2 norm of the difference vector between the predicted and real values:
In: from sklearn.metrics import mean_squared_error     mean_squared_error([-10.0, 0.0, 0.0], [0.0, 0.0, 0.0])Out: 33.333333333333
  • R2 score: R2 is also known as the coefficient of determination. In a nutshell, R2 determines how good a linear fit there ...

Get Python Data Science Essentials - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.