update
This commit is contained in:
@@ -1102,11 +1102,6 @@ You may also find this recent "article":"https://www.pnas.org/content/116/32/158
|
||||
|
||||
!split
|
||||
===== Another Example from Scikit-Learn's Repository =====
|
||||
!bc pycod
|
||||
"""
|
||||
============================
|
||||
Underfitting vs. Overfitting
|
||||
============================
|
||||
|
||||
This example demonstrates the problems of underfitting and overfitting and
|
||||
how we can use linear regression with polynomial features to approximate
|
||||
@@ -1115,17 +1110,19 @@ which is a part of the cosine function. In addition, the samples from the
|
||||
real function and the approximations of different models are displayed. The
|
||||
models have polynomial features of different degrees. We can see that a
|
||||
linear function (polynomial with degree 1) is not sufficient to fit the
|
||||
training samples. This is called **underfitting**. A polynomial of degree 4
|
||||
training samples. This is called _underfitting_. A polynomial of degree 4
|
||||
approximates the true function almost perfectly. However, for higher degrees
|
||||
the model will **overfit** the training data, i.e. it learns the noise of the
|
||||
the model will _overfit_ the training data, i.e. it learns the noise of the
|
||||
training data.
|
||||
We evaluate quantitatively **overfitting** / **underfitting** by using
|
||||
We evaluate quantitatively overfitting and underfitting by using
|
||||
cross-validation. We calculate the mean squared error (MSE) on the validation
|
||||
set, the higher, the less likely the model generalizes correctly from the
|
||||
training data.
|
||||
"""
|
||||
|
||||
print(__doc__)
|
||||
!bc pycod
|
||||
|
||||
|
||||
#print(__doc__)
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
Reference in New Issue
Block a user