GenSVM
Functions
gensvm_gridsearch.h File Reference

Header file for gensvm_gridsearch.c. More...

#include "gensvm_cross_validation.h"
#include "gensvm_cv_util.h"
#include "gensvm_grid.h"
#include "gensvm_queue.h"
#include "gensvm_timer.h"
Include dependency graph for gensvm_gridsearch.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void gensvm_fill_queue (struct GenGrid *grid, struct GenQueue *queue, struct GenData *train_data, struct GenData *test_data)
 Initialize a GenQueue from a Training instance. More...
 
bool gensvm_kernel_changed (struct GenTask *newtask, struct GenTask *oldtask)
 Check if the kernel parameters change between tasks. More...
 
void gensvm_kernel_folds (long folds, struct GenModel *model, struct GenData **train_folds, struct GenData **test_folds)
 Compute the kernels for the folds of the train and test datasets. More...
 
void gensvm_gridsearch_progress (struct GenTask *task, long N, double perf, double duration, double current_max)
 Print the description of the current task on screen. More...
 
void gensvm_train_queue (struct GenQueue *q)
 Run the grid search for a GenQueue. More...
 

Detailed Description

Header file for gensvm_gridsearch.c.

Author
G.J.J. van den Burg
Date
2013-08-01

The grid search for the optimal parameters is done through a queue. This file contains struct definitions for this queue and a single task in a queue, as well as a structure for the complete training scheme. Function declarations are also included.

This file is part of GenSVM.

GenSVM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

GenSVM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GenSVM. If not, see http://www.gnu.org/licenses/.

Definition in file gensvm_gridsearch.h.

Function Documentation

◆ gensvm_fill_queue()

void gensvm_fill_queue ( struct GenGrid grid,
struct GenQueue queue,
struct GenData train_data,
struct GenData test_data 
)

Initialize a GenQueue from a Training instance.

A Training instance describes the grid to search over. This funtion creates all tasks that need to be performed and adds these to a GenQueue. Each task contains a pointer to the train and test datasets which are supplied. Note that the tasks are created in a specific order of the parameters, to ensure that the GenModel::V of a previous parameter set provides the best possible initial estimate of GenModel::V for the next parameter set.

Parameters
[in]gridTraining struct describing the grid search
[in]queuepointer to a GenQueue that will be used to add the tasks to
[in]train_dataGenData of the training set
[in]test_dataGenData of the test set

Definition at line 54 of file gensvm_gridsearch.c.

Here is the call graph for this function:

◆ gensvm_gridsearch_progress()

void gensvm_gridsearch_progress ( struct GenTask task,
long  N,
double  perf,
double  duration,
double  current_max 
)

Print the description of the current task on screen.

To track the progress of the grid search the parameters of the current task are written to the output specified in GENSVM_OUTPUT_FILE. Since the parameters differ with the specified kernel, this function writes a parameter string depending on which kernel is used.

Parameters
[in]taskthe GenTask specified
[in]Ntotal number of tasks
[in]perfperformance of the current task
[in]durationtime duration of the current task
[in]current_maxcurrent best performance

Definition at line 357 of file gensvm_gridsearch.c.

Here is the call graph for this function:

◆ gensvm_kernel_changed()

bool gensvm_kernel_changed ( struct GenTask newtask,
struct GenTask oldtask 
)

Check if the kernel parameters change between tasks.

In the current strategy for training the kernel matrix is decomposed once, and tasks with the same kernel settings are performed sequentially. When a task needs to be done with different kernel parameters, the kernel matrix needs to be recalculated. This function is used to check whether this is the case.

Parameters
[in]newtaskthe next task
[in]oldtaskthe old task
Returns
whether the kernel needs to be reevaluated

Definition at line 195 of file gensvm_gridsearch.c.

◆ gensvm_kernel_folds()

void gensvm_kernel_folds ( long  folds,
struct GenModel model,
struct GenData **  train_folds,
struct GenData **  test_folds 
)

Compute the kernels for the folds of the train and test datasets.

When the kernel parameters change in a kernel grid search, the kernel pre- and post-processing has to be done for the new kernel parameters. This is done here for each of the folds. Each of the training folds is preprocessed, and each of the test folds is postprocessed.

Parameters
[in]foldsnumber of cross validation folds
[in]modelGenModel with new kernel parameters
[in,out]train_foldsarray of train datasets
[in,out]test_foldsarray of test datasets

Definition at line 238 of file gensvm_gridsearch.c.

Here is the call graph for this function:

◆ gensvm_train_queue()

void gensvm_train_queue ( struct GenQueue q)

Run the grid search for a GenQueue.

Given a GenQueue of GenTask struct to be trained, a grid search is launched to find the optimal parameter configuration. As is also done within cross_validation(), the optimal weights of one parameter set are used as initial estimates for GenModel::V in the next parameter set. Note that to optimally exploit this feature of the optimization algorithm, the order in which tasks are considered is important. This is considered in make_queue().

The performance found by cross validation is stored in the GenTask struct.

Parameters
[in,out]qGenQueue with GenTask instances to run

Definition at line 274 of file gensvm_gridsearch.c.

Here is the call graph for this function: