title: Python : sklearn svm, providing a custom loss function
body: <p>The way I use sklearn's svm module now, is to use its defaults. However, its not doing particularly well for my dataset. Is it possible to provide a custom loss function , or a custom kernel? If so, what is the way to write such a function so that it matches with what sklearn's svm expects and how to pass such a function to the trainer?  </p>
  
  <p>There is this example of how to do it:<br>
  <a href="http://scikit-learn.org/stable/auto_examples/svm/plot_custom_kernel.html" rel="noreferrer">SVM custom kernel</a>  </p>
  
  <p>code cited here:  </p>
  
  <pre><code>def my_kernel(x, y):
  """
  We create a custom kernel:
  
               (2  0)
  k(x, y) = x  (    ) y.T
               (0  1)
  """
  M = np.array([[2, 0], [0, 1.0]])
  return np.dot(np.dot(x, M), y.T)
  </code></pre>
  
  <p>I'd like to understand the logic behind this kernel. How to choose the kernel matrix? And what exactly is <code>y.T</code> ?</p>