The svm_toolkit now includes a program svm-demo, which recreates the libsvm applet as a simple application, coded in jruby. The main display, as with libsvm's applet, allows the user to click on a window to enter instances of different classes. Some controls on the right allow the user to set up a kernel and parameters: there are separate fields for entering the cost and gamma values, and a spinner box for selecting a value for degree. Once set up, a click on train updates the display, colouring the background to show which regions are considered as falling in which class.
Below are two screen shots. Both contain the same set of instances: a cluster of blue dots surrounded by some green ones. And in both we use the RBF kernel.
The first has a value for cost of 1, and a value for gamma of 1:

Notice how the decision boundary is curved, but is still not very different from a straight line. The boundary makes three errors: one blue dot is in the green region, and two green dots are in the blue region. We can force the boundary to take more account of errors, by increasing cost, and also to take on a more complicated shape, by increasing gamma. The second example has a value for cost of 10, and a value for gamma of 10:

Notice how the area marked for blue is now almost circular: as the value for gamma is increased, the RBF kernel can generate increasingly complex decision boundaries. Now, the model does not make any errors on the training data.
The gamma parameter is only used by the RBF and sigmoid kernels, and the degree parameter is only used by the polynomial kernel. Below is an example of using the polynomial kernel:

When you install svm_toolkit, svm-demo is made available on the same path as jruby, and so it should be easy to run from the command line.
0 comments:
Post a Comment