nuklei::KernelLogisticRegressor Struct Reference

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...
 

Detailed Description

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.

Examples
klr_classify.cpp.

Definition at line 27 of file KernelLogisticRegressor.h.

Constructor & Destructor Documentation

◆ KernelLogisticRegressor() [1/2]

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.

◆ KernelLogisticRegressor() [2/2]

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.

Member Function Documentation

◆ setData()

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.

◆ test()

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.

◆ train()

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.

Examples
klr_classify.cpp.

Definition at line 62 of file KernelLogisticRegressor.cpp.

◆ vklr()

const GMatrix& nuklei::KernelLogisticRegressor::vklr ( ) const
inline

Returns KLR weights.

The parameter delta is the regularization constant.

Definition at line 107 of file KernelLogisticRegressor.h.


The documentation for this struct was generated from the following files:
© Copyright 2007-2013 Renaud Detry.
Distributed under the terms of the GNU General Public License (GPL).
(See accompanying file LICENSE.txt or copy at http://www.gnu.org/copyleft/gpl.html.)
Revised Sun Sep 13 2020 19:10:10.