NPL
Neurological Programs and Libraries
npl::Classifier Class Referenceabstract

Base class for all ND classifiers. More...

#include <statistics.h>

Inherited by npl::ExpMax, and npl::KMeans.

Public Member Functions

 Classifier (size_t rank)
 Initializes the classifier. More...
 
virtual Eigen::VectorXi classify (const Ref< const MatrixXd > samples)=0
 Given a matrix of samples (Samples x Dims, sample on each row), apply the classifier to each sample and return a vector of the classes. More...
 
virtual size_t classify (const Ref< const MatrixXd > samples, Ref< VectorXi > oclass)=0
 Given a matrix of samples (Samples x Dims, sample on each row), apply the classifier to each sample and return a vector of the classes. More...
 
virtual int update (const Ref< const MatrixXd > samples, bool reinit=false)=0
 Updates the classifier with new samples, if reinit is true then no prior information will be used. If reinit is false then any existing information will be left intact. In Kmeans that would mean that the means will be left at their previous state. More...
 
void compute (const Ref< const MatrixXd > samples)
 Alias for updateClasses with reinit = true. This will perform a classification scheme on all the input samples. More...
 

Public Attributes

const int ndim
 Number of dimensions, must be set at construction. This is the number of columns in input samples. More...
 
int maxit
 Maximum number of iterations. Set below 0 for infinite. More...
 

Protected Attributes

bool m_valid
 Whether the classifier has been initialized yet. More...
 

Detailed Description

Base class for all ND classifiers.

Definition at line 656 of file statistics.h.

Constructor & Destructor Documentation

npl::Classifier::Classifier ( size_t  rank)
inline

Initializes the classifier.

Parameters
rankNumber of dimensions of samples

Definition at line 664 of file statistics.h.

Member Function Documentation

virtual Eigen::VectorXi npl::Classifier::classify ( const Ref< const MatrixXd >  samples)
pure virtual

Given a matrix of samples (Samples x Dims, sample on each row), apply the classifier to each sample and return a vector of the classes.

Parameters
samplesSet of samples, 1 per row
Returns
Vector of classes, rows match up with input sample rows

Implemented in npl::ExpMax, and npl::KMeans.

virtual size_t npl::Classifier::classify ( const Ref< const MatrixXd >  samples,
Ref< VectorXi >  oclass 
)
pure virtual

Given a matrix of samples (Samples x Dims, sample on each row), apply the classifier to each sample and return a vector of the classes.

Parameters
samplesSet of samples, 1 per row
oclassOutput classes. This vector will be resized to have the same number of rows as samples matrix.
Returns
the number of changed classifications

Implemented in npl::ExpMax, and npl::KMeans.

void npl::Classifier::compute ( const Ref< const MatrixXd >  samples)
inline

Alias for updateClasses with reinit = true. This will perform a classification scheme on all the input samples.

Parameters
samplesSamples, S x D matrix with S is the number of samples and D is the dimensionality. This must match the internal dimension count.

Definition at line 713 of file statistics.h.

virtual int npl::Classifier::update ( const Ref< const MatrixXd >  samples,
bool  reinit = false 
)
pure virtual

Updates the classifier with new samples, if reinit is true then no prior information will be used. If reinit is false then any existing information will be left intact. In Kmeans that would mean that the means will be left at their previous state.

Parameters
samplesSamples, S x D matrix with S is the number of samples and D is the dimensionality. This must match the internal dimension count.
reinitwhether to reinitialize the classifier before updating

return -1 if maximum number of iterations hit, 0 otherwise (converged)

Implemented in npl::ExpMax, and npl::KMeans.

Member Data Documentation

bool npl::Classifier::m_valid
protected

Whether the classifier has been initialized yet.

Definition at line 732 of file statistics.h.

int npl::Classifier::maxit

Maximum number of iterations. Set below 0 for infinite.

Definition at line 727 of file statistics.h.

const int npl::Classifier::ndim

Number of dimensions, must be set at construction. This is the number of columns in input samples.

Definition at line 716 of file statistics.h.


The documentation for this class was generated from the following file: