GenSVM
|
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"
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... | |
Header file for gensvm_gridsearch.c.
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.
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.
[in] | grid | Training struct describing the grid search |
[in] | queue | pointer to a GenQueue that will be used to add the tasks to |
[in] | train_data | GenData of the training set |
[in] | test_data | GenData of the test set |
Definition at line 54 of file gensvm_gridsearch.c.
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.
[in] | task | the GenTask specified |
[in] | N | total number of tasks |
[in] | perf | performance of the current task |
[in] | duration | time duration of the current task |
[in] | current_max | current best performance |
Definition at line 357 of file gensvm_gridsearch.c.
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.
[in] | newtask | the next task |
[in] | oldtask | the old task |
Definition at line 195 of file gensvm_gridsearch.c.
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.
[in] | folds | number of cross validation folds |
[in] | model | GenModel with new kernel parameters |
[in,out] | train_folds | array of train datasets |
[in,out] | test_folds | array of test datasets |
Definition at line 238 of file gensvm_gridsearch.c.
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.
Definition at line 274 of file gensvm_gridsearch.c.