Last active
December 16, 2015 16:58
-
-
Save AlexanderFabisch/5466584 to your computer and use it in GitHub Desktop.
Plot that depicts generalization problems that can occur when training a classifier.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
import pylab | |
steps = 100 | |
zeros = numpy.zeros(steps) | |
ideal = numpy.linspace(0, 1, steps) | |
pylab.figure() | |
pylab.xlabel("Training Error") | |
pylab.ylabel("Test Error") | |
pylab.fill_between(ideal, zeros, ideal) | |
pylab.text(0.03, 0.02, "Theoretically impossible", verticalalignment="bottom", | |
horizontalalignment="left", color="white", fontsize=10) | |
pylab.fill_between(ideal, ideal, ideal+0.1, color="g") | |
pylab.text(0.05, 0.15, "Optimum", verticalalignment="bottom", horizontalalignment="left", | |
color="white", fontsize=10) | |
pylab.fill_between(ideal, ideal+0.1, 1, color="r") | |
pylab.text(0.02, 0.5, "Overfitting", verticalalignment="bottom", horizontalalignment="left", | |
color="k", fontsize=10) | |
pylab.fill_between(numpy.array([0.2, 1]), 0, 1, color="orange") | |
pylab.text(0.8, 0.5, "Underfitting", verticalalignment="bottom", horizontalalignment="right", | |
color="k", fontsize=15) | |
pylab.gca().set_xlim([0, 1]) | |
pylab.gca().set_ylim([0, 1]) | |
pylab.legend() | |
pylab.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment