2d-epochs-overfitting.tex 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. \documentclass[varwidth=true, border=2pt]{standalone}
  2. \usepackage{pgfplots}
  3. \usepackage{tikz}
  4. \usetikzlibrary{positioning}
  5. \usetikzlibrary{decorations.text}
  6. \usetikzlibrary{decorations.pathmorphing}
  7. \begin{document}
  8. \begin{tikzpicture}
  9. \begin{axis}[
  10. legend pos=north east,
  11. axis x line=middle,
  12. axis y line=middle,
  13. grid = major,
  14. %width=9cm,
  15. %height=4.5cm,
  16. grid style={dashed, gray!30},
  17. xmin=-1, % start the diagram at this x-coordinate
  18. xmax= 100, % end the diagram at this x-coordinate
  19. ymin=-0.01, % start the diagram at this y-coordinate
  20. ymax= 0.98, % end the diagram at this y-coordinate
  21. axis background/.style={fill=white},
  22. xlabel=Epochs,
  23. ylabel=Error,
  24. %xticklabels={-2,-1.6,...,7},
  25. %yticklabels={-8,-7,...,8},
  26. tick align=outside,
  27. minor tick num=-3,
  28. enlargelimits=true,
  29. tension=0.08]
  30. \addplot[domain=2:50, red, thick,samples=200] {(x-50)^2/2700 + 0.1};
  31. \addplot[domain=4:50, green, thick,samples=200] {(x-50)^2/2700 + 0.2};
  32. \addplot[domain=50:100, red, thick,samples=200] {0.1};
  33. \addplot[domain=50:100, green, thick,samples=200] {(x-50)^2/10000 + 0.2};
  34. \draw[dashed] (axis cs:50,0.1) -- (axis cs:50,0.2);
  35. \draw[decoration={text along path, text={overfitting}, text align={center}}, decorate] (axis cs:51,0.15) -- (axis cs:90,0.15);
  36. \draw[->] (axis cs:51,0.15) -- (axis cs:90,0.15);
  37. \addlegendentry{Training}
  38. \addlegendentry{Testing}
  39. \end{axis}
  40. \end{tikzpicture}
  41. \end{document}