GenSVM
Functions
gensvm_init.c File Reference

Functions for initializing model and data structures. More...

#include "gensvm_init.h"
#include "gensvm_print.h"
Include dependency graph for gensvm_init.c:

Go to the source code of this file.

Functions

void gensvm_init_V (struct GenModel *from_model, struct GenModel *to_model, struct GenData *data)
 Seed the matrix V from an existing model or using rand. More...
 
void gensvm_initialize_weights (struct GenData *data, struct GenModel *model)
 Initialize instance weights. More...
 

Detailed Description

Functions for initializing model and data structures.

Author
G.J.J. van den Burg
Date
2014-01-07

This file contains functions for initializing a GenModel instance and a GenData instance. In addition, default values for these structures are defined here (and only here). Functions for allocating memory for the model structure and freeing of the model and data structures 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_init.c.

Function Documentation

◆ gensvm_init_V()

void gensvm_init_V ( struct GenModel from_model,
struct GenModel to_model,
struct GenData data 
)

Seed the matrix V from an existing model or using rand.

The matrix V must be seeded before the main_loop() can start. This can be done by either seeding it with random numbers or using the solution from a previous model on the same dataset as initial seed. The latter option usually allows for a significant improvement in the number of iterations necessary because the seeded model V is closer to the optimal V.

When no seed model is supplied, the rows of V are seeded with random numbers between the inverse of the minimum and the inverse of the maximum of the corresponding column of Z. This is done to center the product of the two in the simplex space.

Parameters
[in]from_modelGenModel from which to copy V
[in,out]to_modelGenModel to which V will be copied
[in]dataGenData structure with the data

Definition at line 57 of file gensvm_init.c.

◆ gensvm_initialize_weights()

void gensvm_initialize_weights ( struct GenData data,
struct GenModel model 
)

Initialize instance weights.

Instance weights can for instance be used to add additional weights to instances of certain classes. Two default weight possibilities are implemented here. The first is unit weights, where each instance gets weight 1.

The second are group size correction weights, which are calculated as

\[ \rho_i = \frac{n}{Kn_k} , \]

where $ n_k $ is the number of instances in group $ k $ and $ y_i = k $.

Parameters
[in]dataGenData with the dataset
[in,out]modelGenModel with the weight specification. On exit GenModel::rho contains the instance weights.

Definition at line 152 of file gensvm_init.c.

Here is the call graph for this function: