Installing and using KRLS


Installation

  1. Download krls.cc
  2. Compile and link using your favorite C compiler. E.g., in Linux with gcc use:  gcc -lm -O4 krls.cc -o krls
  3. Make sure  krls is executable and move it to whichever directory you keep your binaries in (e.g.  mv krls ~/bin/)
  4. Make sure this directory is in your path. As a test type at the prompt  krls and you should get something like this:
   > krls
  Usage:  krls <data_file_name> [-n <nu>] [-l <lambda>] [-k <kernel_type> [<kernel parameters>]]


Using KRLS

Data file format

The first argument in the krls command line is the name of the file containing the training data.
For convenience let us call it train.dat.
train.dat must be a text (ascii) file formatted as follows:
As an example, the following lines would be a legitimate training data file:

10 3
-6.1853842222 4.2105383846 24.2510572894
-4.5515477082 -4.2238582389 -3.6370868415
-7.7332734160 6.4647596132 8.6893444863
-3.1436871167 0.5007044934 -17.4408302964
0.8256107343 -7.3478642898 -16.9069513199
-3.7197511433 -2.1930623437 1.8644588715
3.2695888974 8.8787482438 10.5602292682
-2.6880661190 -9.6067807173 -22.4837735887
5.0113557013 5.3437077515 -10.3729388875
-6.4020713034 -4.7921000316 3.5506177373

KRLS command line

By typing krls at the prompt you are reminded of the correct syntax of the krls command:

> krls
Usage:  krls <data_file_name> [-n <nu>] [-l <lambda>] [-k <kernel_type> [<kernel parameters>]]


This simply means that:
  1. <data_file_name> is the only non optional argument. In our convention it should be  train.dat.
  2. The   -n option allows to specify the value of <nu>. Otherwise, a default value of 0.01 is used.
  3. The   -l option allows to specify the value of <lambda>. Otherwise, a default value of 0.1 is used.
  4. The   -k option allows to specify the type of kernel to be used. Currently  <kernel_type> may equal either 0 or 1 or 2
  5. If the  -k option is invoked the user is allowed to specify up to 3 kernel parameters. These parameters are identified by their order of appearance. Any prefix of the three is also acceptable, with the rest given their default values, if required.  These parameters are:

Some examples:

krls train.dat
Runs KRLS on the data file train.dat with a Gaussian kernel and default parameters.

krls train.dat -n 0.001 -k 1 3
Runs KRLS on the data file train.dat with a polynomial kernel of degree 3 and default parameters, except nu that is set to 0.001.

krls train.dat -k 1 3 1 0
Runs KRLS on the data file train.dat with a polynomial kernel of degree 3,  b=1 and  c=0 (the homogeneous polynomial kernel). nu and lambda are at their default values.

Output format

KRLS outputs to the file <data_file_name>.out, i.e. in our convention this file would be train.dat.out.
This file consists of only 3 lines:
  1. The 1st line consists of a single integer that gives the number of dictionary vectors used by KRLS
  2. The 2nd line is a list of space separated integers giving the indices of the dictionary vectors in the original data file. Each such index is simply the line number of the respective sample in  train.dat, if the first header line is counted as line number 0.
  3. The 3rd line is a list of space separated floating point numbers (same length as the previous list), each giving the value of the alpha coefficient corresponding to its respective dictionary vector.
Note that the dictionary vectors themselves do not appear in the output file. One must obtain them from train.dat using the indices appearing on the 2nd line of train.dat.out.