code: def main():
      # In this example, we have three types of samples: class 0, 1, or 2.  That
      # is, each of our sample vectors falls into one of three classes.  To keep
      # this example very simple, each sample vector is zero everywhere except at
      # one place.  The non-zero dimension of each vector determines the class of
      # the vector.  So for example, the first element of samples has a class of 1
      # because samples[0][1] is the only non-zero element of samples[0].
      samples = [[0, 2, 0], [1, 0, 0], [0, 4, 0], [0, 0, 3]]
      # Since we want to use a machine learning method to learn a 3-class
      # classifier we need to record the labels of our samples.  Here samples[i]
      # has a class label of labels[i].
      labels = [1, 0, 1, 2]
  
      # Now that we have some training data we can tell the structural SVM to
      # learn the parameters of our 3-class classifier model.  The details of this
      # will be explained later.  For now, just note that it finds the weights
      # (i.e. a vector of real valued parameters) such that predict_label(weights,
      # sample) always returns the correct label for a sample vector.
      problem = ThreeClassClassifierProblem(samples, labels)
      weights = dlib.solve_structural_svm_problem(problem)
  
      # Print the weights and then evaluate predict_label() on each of our
      # training samples. Note that the correct label is predicted for each
      # sample.
      print(weights)
      for k, s in enumerate(samples):
          print(
              "Predicted label for sample[{0}]: {1}".format(
                  k, predict_label(weights, s)
              )
          )
  
file_path: dlib/python_examples/svm_struct.py
imports: import dlib
label_desc: Use image node_id 1 for calling a global function with example usage: main() without return types