I am trying to copy this illustration of the basic idea of SVM, however, I only ever got as far as the code below. I do not understand how I get the circle to look the way it does in the original, further I have trouble labeling everything correctly.

I would greatly appreciate some pointer, thank you!

   \draw[help lines, color=gray!30, dashed] (-0.1,-0.1) grid (2.1,2.1); 
   \draw[->,thick] (0,0)--(2,0) node[right]{$x-axis$}; 
   \draw[->, thick] (0,0)--(0,2) node[above]{$y-axis$}; 
   \draw[dashed] (1,0) arc (0:90:1) node[below]{(1,0)}; 

SVM coordinate system

  • Welcome to TeX SE! What are the angles of the arrows, or is that supposed to be cosmetic? – Alenanno Sep 8 '16 at 7:48
  • The angle can be anything, theta is just there to illustrate that the smaller it is the more similar a and b are. Support Vector Machine (SVM) can be used to determine how similar to words are in their meaning, for example.. – MissSophia Sep 8 '16 at 7:51
  • Isn't that cosine-similarity which is only loosely related to SVMs? – MaPePeR Sep 8 '16 at 8:01
  • It is, but if you would like to explain how SVM works for semantics, then this is the easiest way to do so, especially to non-math-machine-learning savvy people – MissSophia Sep 8 '16 at 8:21
  • isn't "maximum margin hyperplane" an easy explaination for non-math-machine-learning savvy people? ;) – MaPePeR Sep 8 '16 at 8:25

Here is my attempt at recreating that image, but for the future i would recommend you to put a little bit more effort into trying to find a solution yourself.

%   \draw[help lines, color=gray!30, dashed] (-0.1,-0.1) grid (2.1,2.1); 
   \draw[->,thick] (0,0)--(\radius + 1.5,0) node[anchor=north east]{x-axis}; 
   \draw[->, thick] (0,0)--(0,\radius + 1.5) node[anchor=south east, rotate=90]{y-axis}; 
   \draw[dashed] (-15:\radius) arc (-15:90+25:\radius); 
\draw[->,dashdotted] (0,0) -- +(17:\radius) node[right] {$a=(x_1,y_1)$};
\draw[->,dashdotted] (0,0) -- +(55:\radius) node[right] {$b=(x_2,y_2)$};
\draw[dashed] (17:0.5*\radius) arc (17:55:0.5*\radius) node[pos=0.5, anchor=south west] {$\theta$};
\node[anchor=north east] at (0,\radius) {$(0,1)$};
\node[anchor=north east] at (\radius,0) {$(1,0)$};

enter image description here


Should get you some of the way there:

\tikzset{dash dot dot/.style={
  dash pattern={on 4pt off 2pt on 1pt off 2pt on 1pt off 2pt}
\begin{tikzpicture}[>=stealth, x=3cm, y=3cm]
  \draw [->, line cap=rect] (0,0) -- (1.5,0)
    node [at end, below] {$x$-axis};
  \draw [->, line cap=rect] (0,0) -- (0,1.5)
    node [sloped, at end, above] {$y$-axis};
  \draw [dashed] (-10:1) arc (-10:100:1);
  \draw [dash dot dot, ->] (0,0) -- (20:1)
    node [at end, above right] {$a=(x_1,y_1)$};
  \draw [dash dot dot, ->] (0,0) -- (70:1)
    node [at end, above right] {$b=(x_2,y_2)$};
  \draw [dashed] (20:0.5) arc (20:70:0.5)
    node [midway, above right] {$\theta$};
  \foreach \p in {(1,0), (0,1), (0,0)}
    \node at \p [below left] {$\p$};

enter image description here


It is often easier to use polar coordinates for the arcs.


  \draw[help lines, color=gray!30, dashed] (-0.1,-0.1) grid (2.1,2.1); 
  \draw[->,thick] (0,0)--(1.5,0) node[anchor=north east]{\textit{x-axis}}; 
  \draw[->, thick] (0,0)--(0,1.5) node[rotate=90,anchor=south east]{\textit{y-axis}}; 
  \node[anchor=north east] at (0,1) {$(0,1)$};
  \node[anchor=north east] at (1,0) {$(1,0)$};
  \node[anchor=north] at (0,0) {\begin{tabular}{l}
                                  Origin\\ $(0,0)$
  \draw[dashed] (100:1) arc (100:-10:1); 
  \draw[dashdotted,->] (0,0)--(30:1)node[anchor=south west]{$a=(x_1,y_1)$};
  \draw[dashdotted,->] (0,0)--(60:1)node[anchor=south west]{$b=(x_2,y_2)$};
  \draw[dashed] (30:0.4) arc (30:60:0.4) node[anchor=south west,pos=0.5]{$\theta$};


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.