Loading...
Searching...
No Matches
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, Eigen::VectorXd &w)
| Kernel (Model *m, const LinearModel &lm, int column)
| ~Kernel ()

## Attributes

int | type
double | par1
double | par2
String | equation1
String | equation2
Model * | model_
Eigen::VectorXd | weights_
class | FeatureSelection

## Accessors

void | calculateKernelMatrix (Eigen::MatrixXd &input, Eigen::MatrixXd &output)
void | calculateKernelMatrix (Eigen::MatrixXd &K, Eigen::MatrixXd &m1, Eigen::MatrixXd &m2, Eigen::MatrixXd &output)
void | calculateKernelVector (Eigen::MatrixXd &K, Eigen::VectorXd &m1, Eigen::MatrixXd &m2, Eigen::RowVectorXd &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 (Eigen::MatrixXd &input, Eigen::MatrixXd &output)
void | calculateWeightedKernelMatrix (Eigen::MatrixXd &m1, Eigen::MatrixXd &m2, Eigen::MatrixXd &output)
void | calculateKernelMatrix1 (Eigen::MatrixXd &input, Eigen::MatrixXd &output)
void | calculateKernelMatrix2 (Eigen::MatrixXd &input, Eigen::MatrixXd &output)
void | calculateKernelMatrix3 (Eigen::MatrixXd &input, Eigen::MatrixXd &output)
void | calculateKernelMatrix4 (Eigen::MatrixXd &input, Eigen::MatrixXd &output)
void | calculateKernelMatrix1 (Eigen::MatrixXd &m1, Eigen::MatrixXd &m2, Eigen::MatrixXd &output)
void | calculateKernelMatrix2 (Eigen::MatrixXd &m1, Eigen::MatrixXd &m2, Eigen::MatrixXd &output)
void | calculateKernelMatrix3 (Eigen::MatrixXd &m1, Eigen::MatrixXd &m2, Eigen::MatrixXd &output)
void | calculateKernelMatrix4 (Eigen::MatrixXd &m1, Eigen::MatrixXd &m2, Eigen::MatrixXd &output)

## Detailed Description

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

## Constructor & Destructor Documentation

## Kernel() [1/4]

BALL::QSAR::Kernel::Kernel | ( | Model * | m,
|  | int | k_type,
|  | double | p1,
|  | double | p2 = -1 )

## Kernel() [2/4]

BALL::QSAR::Kernel::Kernel | ( | Model * | m,
|  | String | f,
|  | String | g )

## Kernel() [3/4]

BALL::QSAR::Kernel::Kernel | ( | Model * | m,
|  | Eigen::VectorXd & | w )

## Kernel() [4/4]

BALL::QSAR::Kernel::Kernel | ( | Model * | m,
|  | const LinearModel & | lm,
|  | int | column )

constructor for weighted distance kernel.

Parameters

  column | no of column of LinearModel.training_result that is to be used as weights vector

## ~Kernel()

BALL::QSAR::Kernel::~Kernel | ( |  | ) |

## Member Function Documentation

## calculateKernelMatrix() [1/2]

void BALL::QSAR::Kernel::calculateKernelMatrix | ( | Eigen::MatrixXd & | input,
|  | Eigen::MatrixXd & | output )

calculates pairwise distances between all substances in Eigen::MatrixXd input and saves them to Eigen::MatrixXd output.
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 , with m=#descriptors
Else: distance is calculated as

## calculateKernelMatrix() [2/2]

void BALL::QSAR::Kernel::calculateKernelMatrix | ( | Eigen::MatrixXd & | K,
|  | Eigen::MatrixXd & | m1,
|  | Eigen::MatrixXd & | m2,
|  | Eigen::MatrixXd & | output )

calculates pairwise distance between all substances of m1 and m2 and saves them to Eigen::MatrixXd output.
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 , with m=#descriptors
Else: distance is calculated as

## calculateKernelMatrix1() [1/2]

void BALL::QSAR::Kernel::calculateKernelMatrix1 | ( | Eigen::MatrixXd & | input,
|  | Eigen::MatrixXd & | output )

protected

## calculateKernelMatrix1() [2/2]

void BALL::QSAR::Kernel::calculateKernelMatrix1 | ( | Eigen::MatrixXd & | m1,
|  | Eigen::MatrixXd & | m2,
|  | Eigen::MatrixXd & | output )

protected

## calculateKernelMatrix2() [1/2]

void BALL::QSAR::Kernel::calculateKernelMatrix2 | ( | Eigen::MatrixXd & | input,
|  | Eigen::MatrixXd & | output )

protected

## calculateKernelMatrix2() [2/2]

void BALL::QSAR::Kernel::calculateKernelMatrix2 | ( | Eigen::MatrixXd & | m1,
|  | Eigen::MatrixXd & | m2,
|  | Eigen::MatrixXd & | output )

protected

## calculateKernelMatrix3() [1/2]

void BALL::QSAR::Kernel::calculateKernelMatrix3 | ( | Eigen::MatrixXd & | input,
|  | Eigen::MatrixXd & | output )

protected

## calculateKernelMatrix3() [2/2]

void BALL::QSAR::Kernel::calculateKernelMatrix3 | ( | Eigen::MatrixXd & | m1,
|  | Eigen::MatrixXd & | m2,
|  | Eigen::MatrixXd & | output )

protected

## calculateKernelMatrix4() [1/2]

void BALL::QSAR::Kernel::calculateKernelMatrix4 | ( | Eigen::MatrixXd & | input,
|  | Eigen::MatrixXd & | output )

protected

## calculateKernelMatrix4() [2/2]

void BALL::QSAR::Kernel::calculateKernelMatrix4 | ( | Eigen::MatrixXd & | m1,
|  | Eigen::MatrixXd & | m2,
|  | Eigen::MatrixXd & | output )

protected

## calculateKernelVector()

void BALL::QSAR::Kernel::calculateKernelVector | ( | Eigen::MatrixXd & | K,
|  | Eigen::VectorXd & | m1,
|  | Eigen::MatrixXd & | m2,
|  | Eigen::RowVectorXd & | output )

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

## calculateWeightedKernelMatrix() [1/2]

void BALL::QSAR::Kernel::calculateWeightedKernelMatrix | ( | Eigen::MatrixXd & | input,
|  | Eigen::MatrixXd & | output )

protected

calculates pairwise distances between all substances in Eigen::MatrixXd input, weighted by the contribution of every descriptor (as encoded in Kernel.weights), and saves them to Eigen::MatrixXd output.
Distance between two substances a and b is calculated as , with m=#descriptors

## calculateWeightedKernelMatrix() [2/2]

void BALL::QSAR::Kernel::calculateWeightedKernelMatrix | ( | Eigen::MatrixXd & | m1,
|  | Eigen::MatrixXd & | m2,
|  | Eigen::MatrixXd & | 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 Eigen::MatrixXd output.
Distance between two substances a and b is calculated as , with m=#descriptors

## gridSearch() [1/2]

void BALL::QSAR::Kernel::gridSearch | ( | double | step_width,
|  | int | steps,
|  | bool | first_rec,
|  | int | k,
|  | double | par1_start,
|  | double | par2_start,
|  | bool | opt )

protected

## gridSearch() [2/2]

void BALL::QSAR::Kernel::gridSearch | ( | double | step_width,
|  | int | steps,
|  | int | recursions,
|  | int | k,
|  | bool | opt = 0 )

grid search for the best kernel parameters.
Grid search is done locally around the current kernel parameter value(s).

Parameters

  opt | if ==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_width | the size of each step to be made
  steps | the number of steps for grid search
  recursions | number 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

## Friends And Related Symbol Documentation

## FeatureSelection

friend class FeatureSelection

friend

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

## Member Data Documentation

## equation1

String BALL::QSAR::Kernel::equation1

Equation for distance function for calculation of kernel matrix.
Distance of two substances a and b is calculated as , with m=#descriptors
Use "x1" and "x2" in the String, e.g. "x1*x2"

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

## equation2

String BALL::QSAR::Kernel::equation2

Equation for distance function for calculation of kernel matrix.
Distance of two substances a and b is calculated as , 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 105 of file QSAR/kernel.h.

## model_

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

protected

pointer to the model which uses this kernel

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

## par1

double BALL::QSAR::Kernel::par1

parameters for kernel functions set by the user

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

## par2

double BALL::QSAR::Kernel::par2

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

## type

int BALL::QSAR::Kernel::type

specifies which kind of kernel is chosen:
1 = polynomial kernel
2 = radial basis function kernel
3 = sigmoid kernel
4 = individual kernel-function
5 = weighted distance kernel

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

## weights_

Eigen::VectorXd BALL::QSAR::Kernel::weights_

protected

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