# Structured SVMs

## The Method and When to Use it

Structured (or Structural) Support Vector Machines (SSVM), as the name states, is a machine learning model that generalizes the Support Vector Machine (SVM) classifier, allowing training a classifier for structured output.

In general, SSVMs perform supervised learning by approximating a mapping ${\displaystyle f}$

${\displaystyle f:X\rightarrow Y}$

where ${\displaystyle x=\{(x_{1},y_{1}),...,(x_{n},y_{n})\}}$ is a set of labeled training examples and ${\displaystyle Y}$ is a complex structured object, like trees, sequences, or sets, instead of simple univariate predictions (as in the SVM case).

Thus, training a SSVM classifier consists of showing pairs of correct sample and output label pairs, that are used for training, allowing to predict for new sample instances the corresponding output label

In NLP one can fing a great variety of problems that rely on complex outputs, such as parsing and Markov Models for part-of-speech tagging.

## Training

While on training, for a set of samples and labels ${\displaystyle (x_{n},y_{n})\in X\times Y,n=1,...,l}$, the SSVM minimizes the risk function:

${\displaystyle \min _{w}||w||^{2}+C\sum _{n=1}^{l}\max _{y\in Y}(\Delta (y_{n},y)+w'\Psi (x_{n},y)-w'\Psi (x_{n},y_{n}))}$

where ${\displaystyle \Delta }$ is an arbitrary function, which measures the distance between to labels and ${\displaystyle \Psi }$ is a function on samples and labels, which extracts feature vectors. These two function are to be defined according to the problem at hand

Since the equation above is non-differentiable, one can reformulate it introducing slack variables, ${\displaystyle \xi _{n}}$, representing the value of the maximum. Using this approach the SSVM comes as:

${\displaystyle \min _{w,\xi }||w||^{2}+C\sum _{n=1}^{l}\xi _{n}}$

      ${\displaystyle s.t.w'\Psi (x_{n},y_{n})-w'\Psi (x_{n},y)+\xi _{n}\geq \Delta (y_{n},y),n=1,...,l\forall y\in Y}$

      ${\displaystyle \xi _{n}\geq 0,n=1,...,l}$


## Testing

Given a sample, ${\displaystyle x\in X}$ and a mapping ${\displaystyle f:X\rightarrow Y}$ one can obtain the correspondent lable. The mapping is defined as

${\displaystyle f(x)=\arg \max _{y\in Y}w'\Psi (x,y)}$

where ${\displaystyle w}$ is the vector during the training phase.

The inference problem of solving for this maximizer over the label space is dependent on the structure of the function ${\displaystyle \Psi }$ that varies according to the problem.