BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Friends | List of all members
BALL::QSAR::Kernel Class Reference

#include <BALL/QSAR/kernel.h>

Public Member Functions

Constructors and Destructors
 Kernel (Model *m, int k_type, double p1, double p2=-1)
 
 Kernel (Model *m, String f, String g)
 
 Kernel (Model *m, Vector< double > &w)
 
 Kernel (Model *m, const LinearModel &lm, int column)
 
 ~Kernel ()
 

Friends

class FeatureSelection
 

Accessors

void calculateKernelMatrix (Matrix< double > &input, Matrix< double > &output)
 
void calculateKernelMatrix (Matrix< double > &K, Matrix< double > &m1, Matrix< double > &m2, Matrix< double > &output)
 
void calculateKernelVector (Matrix< double > &K, Vector< double > &m1, Matrix< double > &m2, Vector< double > &output)
 
void gridSearch (double step_width, int steps, int recursions, int k, bool opt=0)
 
void gridSearch (double step_width, int steps, bool first_rec, int k, double par1_start, double par2_start, bool opt)
 
void calculateWeightedKernelMatrix (Matrix< double > &input, Matrix< double > &output)
 
void calculateWeightedKernelMatrix (Matrix< double > &m1, Matrix< double > &m2, Matrix< double > &output)
 
void calculateKernelMatrix1 (Matrix< double > &input, Matrix< double > &output)
 
void calculateKernelMatrix2 (Matrix< double > &input, Matrix< double > &output)
 
void calculateKernelMatrix3 (Matrix< double > &input, Matrix< double > &output)
 
void calculateKernelMatrix4 (Matrix< double > &input, Matrix< double > &output)
 
void calculateKernelMatrix1 (Matrix< double > &m1, Matrix< double > &m2, Matrix< double > &output)
 
void calculateKernelMatrix2 (Matrix< double > &m1, Matrix< double > &m2, Matrix< double > &output)
 
void calculateKernelMatrix3 (Matrix< double > &m1, Matrix< double > &m2, Matrix< double > &output)
 
void calculateKernelMatrix4 (Matrix< double > &m1, Matrix< double > &m2, Matrix< double > &output)
 

Attributes

int type
 
double par1
 
double par2
 
String equation1
 
String equation2
 
Modelmodel_
 
Vector< doubleweights_
 

Detailed Description

Definition at line 53 of file QSAR/kernel.h.

Constructor & Destructor Documentation

BALL::QSAR::Kernel::Kernel ( Model m,
int  k_type,
double  p1,
double  p2 = -1 
)
BALL::QSAR::Kernel::Kernel ( Model m,
String  f,
String  g 
)
BALL::QSAR::Kernel::Kernel ( Model m,
Vector< double > &  w 
)
BALL::QSAR::Kernel::Kernel ( Model m,
const LinearModel lm,
int  column 
)
constructor for weighted distance kernel.
Parameters
columnno of column of LinearModel.training_result that is to be used as weights vector
BALL::QSAR::Kernel::~Kernel ( )

Member Function Documentation

void BALL::QSAR::Kernel::calculateKernelMatrix ( Matrix< double > &  input,
Matrix< double > &  output 
)
calculates pairwise distances between all substances in Matrix<double> input and saves them to Matrix<double> output.\n

If Kernel.weights is not empty, function Kernel.calculateWeightedDistanceMatrix() is used
Else if: Kernel.f=="" and Kernel.g="", the distance between two substances a and b is calculated as $ \sum_{i=1}^m (input_{ai} * input_{bi})^p $, with m=#descriptors
Else: distance is calculated as $ g(\sum_{i=1}^m f(input_{ai}, input_{bi})) $

void BALL::QSAR::Kernel::calculateKernelMatrix ( Matrix< double > &  K,
Matrix< double > &  m1,
Matrix< double > &  m2,
Matrix< double > &  output 
)
calculates pairwise distance between all substances of m1 and m2 and saves them to Matrix<double> output. \n

If Kernel.weights is not empty, function Kernel.calculateWeightedDistanceMatrix() is used
Esle if: Kernel.f=="" and Kernel.g="", the distance between two substances a and b is calculated as $ \sum_{i=1}^m (m1_{ai} * m2_{bi})^p $, with m=#descriptors
Else: distance is calculated as $ g(\sum_{i=1}^m f(m1_{ai}, m2_{bi})) $

void BALL::QSAR::Kernel::calculateKernelMatrix1 ( Matrix< double > &  input,
Matrix< double > &  output 
)
protected
void BALL::QSAR::Kernel::calculateKernelMatrix1 ( Matrix< double > &  m1,
Matrix< double > &  m2,
Matrix< double > &  output 
)
protected
void BALL::QSAR::Kernel::calculateKernelMatrix2 ( Matrix< double > &  input,
Matrix< double > &  output 
)
protected
void BALL::QSAR::Kernel::calculateKernelMatrix2 ( Matrix< double > &  m1,
Matrix< double > &  m2,
Matrix< double > &  output 
)
protected
void BALL::QSAR::Kernel::calculateKernelMatrix3 ( Matrix< double > &  input,
Matrix< double > &  output 
)
protected
void BALL::QSAR::Kernel::calculateKernelMatrix3 ( Matrix< double > &  m1,
Matrix< double > &  m2,
Matrix< double > &  output 
)
protected
void BALL::QSAR::Kernel::calculateKernelMatrix4 ( Matrix< double > &  input,
Matrix< double > &  output 
)
protected
void BALL::QSAR::Kernel::calculateKernelMatrix4 ( Matrix< double > &  m1,
Matrix< double > &  m2,
Matrix< double > &  output 
)
protected
void BALL::QSAR::Kernel::calculateKernelVector ( Matrix< double > &  K,
Vector< double > &  m1,
Matrix< double > &  m2,
Vector< double > &  output 
)

transforms test data 'input' into the kernel-saves and saves it to matrix 'output'

void BALL::QSAR::Kernel::calculateWeightedKernelMatrix ( Matrix< double > &  input,
Matrix< double > &  output 
)
protected
calculates pairwise distances between all substances in Matrix<double> input, weighted by the contribution of every descriptor (as encoded in Kernel.weights), and saves them to Matrix<double> output.\n

Distance between two substances a and b is calculated as $ \sum_{i=1}^m w_i * (input_{ai}- input_{bi})^2 $, with m=#descriptors

void BALL::QSAR::Kernel::calculateWeightedKernelMatrix ( Matrix< double > &  m1,
Matrix< double > &  m2,
Matrix< double > &  output 
)
protected
calculates pairwise distances between all substances of m1 and m2, weighted by the contribution of every descriptor (as encoded in Kernel.weights), and saves them to Matrix<double> output.\n

Distance between two substances a and b is calculated as $ \sum_{i=1}^m w_i * (m1_{ai}- m2_{bi})^2 $, with m=#descriptors

void BALL::QSAR::Kernel::gridSearch ( double  step_width,
int  steps,
int  recursions,
int  k,
bool  opt = 0 
)
grid search for the best kernel parameters.\n

Grid search is done locally around the current kernel parameter value(s).

Parameters
optif ==1, Model.optitimizeParameters() is used in each step of grid search, optimizing the parameter of the Model in addition to those of the kernel.
step_widththe size of each step to be made
stepsthe number of steps for grid search
recursionsnumber of recursions of grid search; in each recursion the step width is decreased by factor of 10 and searching is done in 20 steps around the values of the best kernel parameters determined in last recursion
void BALL::QSAR::Kernel::gridSearch ( double  step_width,
int  steps,
bool  first_rec,
int  k,
double  par1_start,
double  par2_start,
bool  opt 
)
protected

Friends And Related Function Documentation

friend class FeatureSelection
friend

Definition at line 176 of file QSAR/kernel.h.

Member Data Documentation

String BALL::QSAR::Kernel::equation1
Equation for distance function for calculation of kernel matrix.\n

Distance of two substances a and b is calculated as $ dist(a,b)= g(\sum_{i=1}^m f(x1,x2)) $, with m=#descriptors
Use "x1" and "x2" in the String, e.g. "x1*x2"

Definition at line 121 of file QSAR/kernel.h.

String BALL::QSAR::Kernel::equation2
Equation for distance function for calculation of kernel matrix.\n

Distance of two substances a and b is calculated as $ dist(a,b)= g(\sum_{i=1}^m f(x1,x2)) $, with m=#descriptors
g determines what is to be done with the calculated "sum" over all elements (use "sum" in String); e.g. "sum^0.5" => euclidean distance if f=="x1*x2"

Definition at line 126 of file QSAR/kernel.h.

Model* BALL::QSAR::Kernel::model_
protected

pointer to the model which uses this kernel

Definition at line 170 of file QSAR/kernel.h.

double BALL::QSAR::Kernel::par1

parameters for kernel functions set by the user

Definition at line 116 of file QSAR/kernel.h.

double BALL::QSAR::Kernel::par2

Definition at line 116 of file QSAR/kernel.h.

int BALL::QSAR::Kernel::type
specifies which kind of kernel is chosen:\n

1 = polynomial kernel
2 = radial basis function kernel
3 = sigmoid kernel
4 = individual kernel-function
5 = weighted distance kernel

Definition at line 113 of file QSAR/kernel.h.

Vector<double> BALL::QSAR::Kernel::weights_
protected

Definition at line 172 of file QSAR/kernel.h.