Menu ▾ ▴

Tutorials

Matteo Santoro

GURLS TUTORIAL

The gurls command accepts exaclty four arguments:

  • The data point, stored in a NxD matrix.
  • The data encoded labels stored (for One-Vs-All) in a NxT matrix.
  • An options' structure.
  • A job-id number.

Each time the data need to be changed (e.g. going from training phase to testing phase) gurls needs to be called again.

The three main fields in the options' structure are:

  • opt.name: defines a name for a given experiment.
  • opt.seq: specifies the sequence of tasks to be executed.
  • opt.process: specifies what to do with each task. In particular here are the codes:
    • 0 = Ignore
    • 1 = Compute
    • 2 = Compute and save
    • 3 = Load from file
    • 4 = Explicitly delete

Examples

We want to run the training on a dataset {Xtr,ytr} and the test on a different dataset {Xte,yte}. We are interested in the precision-recall performance measure as well as the average classification accuracy. Here is how to do it.

Linear classifier, primal case, leave one out cv

name = 'ExampleExperiment';
opt = defopt(name);
opt.seq = {'paramsel:loocvprimal','rls:primal','pred:primal','perf:precrec','perf:macroavg'};
opt.process{1} = [2,2,0,0,0];
opt.process{2} = [3,3,2,2,2];
gurls (Xtr, ytr, opt,1)
gurls (Xte, yte, opt,2)

This would read somewhat like:

  • For the training data: calculate λ using loocv and save the result, solve RLS for a linear classifier in the primal space and save the solution. Ignore the rest.
  • For the test data set, load the used &lambda (this is important if you want to save this value for further reference), load the classifier. Predict the output on the test-set and save it. Evaluate the two aforementioned performance measures and save them.

Linear classifier, primal case, hold-out cv

name = 'ExampleExperiment';
opt = defopt(name);
opt.seq = {'split:ho','paramsel:hoprimal','rls:primal','pred:primal','perf:macroavg','perf:precrec'};
opt.process{1} = [2,2,2,0,0,0];
opt.process{2} = [3,3,3,2,2,2];
gurls (Xtr, ytr, opt,1)
gurls (Xte, yte, opt,2)

Linear classifier, dual case, leave one out cv

name = 'ExampleExperiment';
opt = defopt(name);
opt.seq = {'kernel:linear', 'paramsel:loocvdual', 'rls:dual', 'pred:dual', 'perf:macroavg', 'perf:precrec'};
opt.process{1} = [2,2,2,0,0,0];
opt.process{2} = [3,3,3,2,2,2];
gurls (Xtr, ytr, opt,1)
gurls (Xte, yte, opt,2)

Linear classifier, dual case, hold-out cv

name = 'ExampleExperiment';
opt = defopt(name);
opt.seq = {'split:ho', 'kernel:linear', 'paramsel:hodual', 'rls:dual', 'pred:dual', 'perf:macroavg', 'perf:precrec'};
opt.process{1} = [2,2,2,2,0,0,0];
opt.process{2} = [3,3,3,3,2,2,2];
gurls (Xtr, ytr, opt,1)
gurls (Xte, yte, opt,2)

Gaussian Kernel, dual case, leave one out cv

name = 'ExampleExperiment';
opt = defopt(name);
opt.seq = {'paramsel:siglam', 'kernel:rbf', 'rls:dual', 'predkernel:traintest', 'pred:dual', 'perf:macroavg', 'perf:precrec'};
opt.process{1} = [2,2,2,0,0,0,0];
opt.process{2} = [3,3,3,2,2,2,2];
gurls (Xtr, ytr, opt,1)
gurls (Xte, yte, opt,2)

Gaussian Kernel, dual case, hold-out cv

name = 'ExampleExperiment';
opt = defopt(name);
opt.seq = {'split:ho', 'paramsel:siglamho', 'kernel:rbf', 'rls:dual', 'predkernel:traintest', 'pred:dual', 'perf:macroavg', 'perf:precrec'};
opt.process{1} = [2,2,2,2,0,0,0,0];
opt.process{2} = [3,3,3,3,2,2,2,2];
gurls (Xtr, ytr, opt,1)
gurls (Xte, yte, opt,2)


Related

Wiki: Home