From the course: Machine Learning and AI Foundations: Value Estimations

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Measure accuracy with mean absolute error

Measure accuracy with mean absolute error

From the course: Machine Learning and AI Foundations: Value Estimations

Start my 1-month free trial

Measure accuracy with mean absolute error

- [Instructor] After training a machine learning model, the next step is to measure how well the model performs. Let's open up train_model pt4.py. To check the accuracy of our model's predictions, we'll use a measure called mean absolute error. Mean absolute error looks at every prediction our model makes, and it gives us an average of how wrong it was across all the predictions. Scikit-learn provides a simple mean absolute error function that we can use to do this. To use it, we pass in the y values, or the correct answers for our training data set. Then we call model.predict on X, our training features. This will generate a prediction using our training model for each entry in our training data set. Scikit-learn will compare the predictions to the expected answers and tell us how close we are. Now let's do the exact same calculation for our test data set. The only difference here is to make sure to pass in the test data instead of the training data. Let's run this and see the…

Contents