Since I am writing my thesis on machine learning, I wanted to illustrate some issues with this graph this graph using tikz. Right now, I don't know how to do this since I'm a novice at using tikz. Anyone who can help me out? Thank you a lot!

  • 3
    Hello and welcome to the forum! This is an interesting question, but we are no "do this for me"-service. Can you show us what you tried so far?
    – Tim Hilt
    Mar 10, 2020 at 20:16
  • Are you trying to draw this graph with tikz, or just insert it into your paper? Mar 10, 2020 at 21:15
  • @ZizhengYang I am trying to draw this graph using tikz, so that the style of this graph is in accordance with my other tikz pictures. Mar 10, 2020 at 21:22
  • I think you could try tkz-fct, which is a function plotting package build on tikz: link. On section 15.0.2, it shows an example of a quadratic function with tags, I think it would be a helpful example for your project. Mar 10, 2020 at 21:32

1 Answer 1


To give you a start.

\begin{tikzpicture}[thick,font=\sffamily,line cap=round,>=stealth,node
 \draw [<->] (0,5) node[below left]{Loss} |- (7,0) node[below left]{Model complexity};
 \draw (0.8,5) to[bend right=50] node[pos=0.7,above right] {Training loss}(6,0.8);
 \draw (1.2,5) to[out=-80,in=180] (3,3) to[out=0,in=-155]
  node[pos=0.2,below right] {Generalization loss} (6,4);
 \draw[loosely dotted] (3,0) -- (3,5) node[above] (P) {Optimum};
 \path node[base left=of P] (U) {Underfitting}
    node[base right=of P] (O) {Overfitting};
 \draw[->] ([yshift=1ex]U.north east) -- ([yshift=1ex]U.north west);
 \draw[->] ([yshift=1ex]O.north west) -- ([yshift=1ex]O.north east);    

enter image description here

  • Thank you! This helped me a lot. Mar 13, 2020 at 20:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .