Implements kernel logistic regression. More...
#include <KernelLogisticRegressor.h>
Public Member Functions | |
KernelLogisticRegressor (const KernelCollection &data, const std::vector< int > &labels) | |
Imports input from data and labels , and computes the Gram matrix of the data. More... | |
KernelLogisticRegressor (const KernelCollection &data, const GMatrix &gramMatrix, const std::vector< int > &labels) | |
Imports input from data and labels and the Gram matrix gramMatrix . More... | |
void | setData (const KernelCollection &data, const std::vector< int > &labels) |
Imports input from data and labels , and computes the Gram matrix of the data. More... | |
void | train (const double delta=0.0001, const unsigned itrNewton=5) |
Computes KLR weights. More... | |
bool | isTrained () |
Returns true if the classifier has been trained. | |
Vector2 | test (const kernel::base &t) const |
Returns a pair of values which indicate the probability of classes 1 and 2 . | |
GMatrix | test (const KernelCollection &testSet) const |
Returns the probabilities of classes 1 and 2 for all data points in testSet . More... | |
const GMatrix & | vklr () const |
Returns KLR weights. More... | |
Implements kernel logistic regression.
This class implements a two-class nonlinear classifier for \( SE(3) \) data. KLR is discussed in Kernel Logistic Regression.
This class is based on libklr
, which is provided with Makoto Yamada's IWKLR.
Definition at line 27 of file KernelLogisticRegressor.h.
nuklei::KernelLogisticRegressor::KernelLogisticRegressor | ( | const KernelCollection & | data, |
const std::vector< int > & | labels | ||
) |
Imports input from data
and labels
, and computes the Gram matrix of the data.
The two structures data
and labels
should contain the same number of elements. The \( i^{\mathrm{th}} \) element of labels
indicates the class of the \( i^{\mathrm{th}} \) element of data
. The two allowed values in labels
are 1
and 2
.
Definition at line 16 of file KernelLogisticRegressor.cpp.
nuklei::KernelLogisticRegressor::KernelLogisticRegressor | ( | const KernelCollection & | data, |
const GMatrix & | gramMatrix, | ||
const std::vector< int > & | labels | ||
) |
Imports input from data
and labels
and the Gram matrix gramMatrix
.
The two structures data
and labels
should contain the same number of elements. The \( i^{\mathrm{th}} \) element of labels
indicates the class of the \( i^{\mathrm{th}} \) element of data
. The two allowed values in labels
are 1
and 2
.
The data held in gramMatrix
should correspond to the Gram matrix of data
.
Definition at line 27 of file KernelLogisticRegressor.cpp.
References NUKLEI_ASSERT.
void nuklei::KernelLogisticRegressor::setData | ( | const KernelCollection & | data, |
const std::vector< int > & | labels | ||
) |
Imports input from data
and labels
, and computes the Gram matrix of the data.
The two structures data
and labels
should contain the same number of elements. The \( i^{\mathrm{th}} \) element of labels
indicates the class of the \( i^{\mathrm{th}} \) element of data
. The two allowed values in labels
are 1
and 2
.
This method also resets all the other member variables of the class.
Definition at line 38 of file KernelLogisticRegressor.cpp.
GMatrix nuklei::KernelLogisticRegressor::test | ( | const KernelCollection & | testSet | ) | const |
Returns the probabilities of classes 1
and 2
for all data points in testSet
.
This method returns a \( 2 \times n \) matrix, where \( n \) is the number of elements in testSet
.
Definition at line 106 of file KernelLogisticRegressor.cpp.
void nuklei::KernelLogisticRegressor::train | ( | const double | delta = 0.0001 , |
const unsigned | itrNewton = 5 |
||
) |
Computes KLR weights.
The implementation follows Semi-supervised speaker identification under covariate shift.
Definition at line 62 of file KernelLogisticRegressor.cpp.
|
inline |
Returns KLR weights.
The parameter delta
is the regularization constant.
Definition at line 107 of file KernelLogisticRegressor.h.