# ideal algorithms to demonstrate overfitting or underfitting

When one tries to look up concepts such as overfitting and underfitting, the most common thing that pops up is polynomial regression. Why is polynomial regression often used to demonstrate these concepts? Is it just because it can be easily visualised like the graphs here:

https://scikit-learn.org/stable/auto_examples/model_selection/plot_underfitting_overfitting.html

But then most ml algorithm such as kmeans clustering can also be used. Then why is it usually polynomial regression only? Are there any other similar algorithms that could be used?

• almost all algorithms can be used as all have these drawbacks, yet polynomial regression is easily explainable rather than a neural network or decision tree – Nikos M. May 7 at 20:46
Another example you could use is the separation boundaries in decision trees classification problem. In the picture below, you can see that the training error continues to go down (lower the better) when max_depth increases, whereas the testing error is not as good. This is because the model has carved out specific pink areas (for 'x') as the separation boundary based on the training data. When these boundaries are applied to another set of data, they become poor separation boundaries. So these boundaries cannot be generalised to other testing data sets.