February 13, 2017

Hello (kernel) Learning!

A second example that we consider is again a classification task, but this time with a kernelized version of the Passive Aggressive algorithm (KernelizedPassiveAggressiveClassification). The full code of this example can be found in the GitHub repository kelp-full, in particular in the source file HelloKernelLearning.java.

The dataset here used is again the svmlight page dataset, in the KeLP format.
As for the previous example, the dataset is composed by:

  • Training set (2000 examples, 1000 of class “+1” (positive), and 1000 of class “-1” (negative))
  • Test set (600 examples, 300 of class “+1” (positive), and 300 of class “-1” (negative))

Again, loading the dataset is simply a call to KeLP methods:

Using a kernel function within KeLP is very simple: it is sufficient to declare a kernel function, the representation on which it will operate and tell the algorithm the it must use a kernel function to compute similarity scores.

For example, if we want to use a Polynomial kernel on top of a linear kernel, it is sufficient to do as following:

The rest of the Java code is very similar to the one of the Hello (linear) Learning example.