4 Optimizing the training process: Underfitting, overfitting, testing, and regularization

 

In this chapter

  • what is underfitting and overfitting
  • some solutions for avoiding overfitting: testing, the model complexity graph, and regularization
  • calculating the complexity of the model using the L1 and L2 norms
  • picking the best model in terms of performance and complexity

This chapter is different from most of the chapters in this book, because it doesn’t contain a particular machine learning algorithm. Instead, it describes some potential problems that machine learning models may face and effective practical ways to solve them.

Imagine that you have learned some great machine learning algorithms, and you are ready to apply them. You go to work as a data scientist, and your first task is to build a machine learning model for a dataset of customers. You build it and put it in production. However, everything goes wrong, and the model doesn’t do a good job of making predictions. What happened?

It turns out that this story is common, because many things can go wrong with our models. Fortunately, we have several techniques to improve them. In this chapter, I show you two problems that happen often when training models: underfitting and overfitting. I then show you some solutions to avoid underfitting and overfitting our models: testing and validation, the model complexity graph, and regularization.

An example of underfitting and overfitting using polynomial regression

How do we get the computer to pick the right model? By testing

Where did we break the golden rule, and how do we fix it? The validation set

A numerical way to decide how complex our model should be: The model complexity graph

Another alternative to avoiding overfitting: Regularization

Polynomial regression, testing, and regularization with Turi Create

Summary

Exercises

sitemap