XMM - Probabilistic Models for Motion Recognition and Mapping

Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
xmm::SingleClassProbabilisticModel Class Referenceabstract

Generic Template for Machine Learning Probabilistic models based on the EM algorithm. More...

#include <xmmModelSingleClass.hpp>

Inheritance diagram for xmm::SingleClassProbabilisticModel:
[legend]
Collaboration diagram for xmm::SingleClassProbabilisticModel:
[legend]

Public Member Functions

 SingleClassProbabilisticModel (std::shared_ptr< SharedParameters > p=NULL)
 Constructor. More...
 
 SingleClassProbabilisticModel (SingleClassProbabilisticModel const &src)
 Copy Constructor. More...
 
 SingleClassProbabilisticModel (std::shared_ptr< SharedParameters > p, Json::Value const &root)
 Constructor from Json. More...
 
SingleClassProbabilisticModeloperator= (SingleClassProbabilisticModel const &src)
 Assignment. More...
 
virtual ~SingleClassProbabilisticModel ()
 Destructor. More...
 
Training
bool isTraining () const
 Checks if the model is training. More...
 
void train (TrainingSet *trainingSet)
 Main training method based on the EM algorithm. More...
 
void cancelTraining ()
 Cancels the training process : sets a flag so that the training stops at the next possible exit in the training process. More...
 
Performance
virtual void reset ()
 Resets the fitering process (recognition or regression) More...
 
virtual double filter (std::vector< float > const &observation)=0
 filters a incoming observation (performs recognition or regression) More...
 
Json I/O
virtual Json::Value toJson () const
 Write the object to a JSON Structure. More...
 
virtual void fromJson (Json::Value const &root)=0
 Read the object from a JSON Structure. More...
 
Python File I/O
void writeFile (char *fileName) const
 write method for python wrapping ('write' keyword forbidden, name has to be different) More...
 
void readFile (char *fileName)
 read method for python wrapping ('read' keyword forbidden, name has to be different) More...
 
std::string __str__ () const
 "print" method for python => returns the results of write method More...
 

Public Attributes

std::string label
 label associated with the given model More...
 
std::shared_ptr< SharedParametersshared_parameters
 Pointer to the shared parameters owned by a multi-class model. More...
 
EventGenerator< TrainingEventtraining_events
 Generator for events monitoring the training process. More...
 
TrainingEvent training_status
 Event containing information on the current status of the training process. More...
 

Protected Member Functions

virtual void allocate ()=0
 Allocate memory for the model's parameters. More...
 
virtual void emAlgorithmInit (TrainingSet *trainingSet)=0
 Initialize the training algorithm. More...
 
virtual double emAlgorithmUpdate (TrainingSet *trainingSet)=0
 Update Method of the EM algorithm. More...
 
virtual void emAlgorithmTerminate ()
 Terminate the training algorithm. More...
 
bool emAlgorithmHasConverged (int step, double log_prob, double old_log_prob) const
 checks if the training has converged according to the object's EM stop criterion More...
 
bool cancelTrainingIfRequested ()
 checks if a cancel request has been sent and accordingly cancels the training process More...
 
void check_training () const
 Checks if the model is still training. More...
 

Protected Attributes

CircularBuffer< double > likelihood_buffer_
 Likelihood buffer used for smoothing. More...
 
std::mutex training_mutex_
 Mutex used in Concurrent Mode. More...
 
bool is_training_
 defines if the model is being trained. More...
 
bool cancel_training_
 defines if the model received a request to cancel training More...
 

Detailed Description

Generic Template for Machine Learning Probabilistic models based on the EM algorithm.

Constructor & Destructor Documentation

xmm::SingleClassProbabilisticModel::SingleClassProbabilisticModel ( std::shared_ptr< SharedParameters p = NULL)

Constructor.

Parameters
ppointer to a shared parameters object (owned by a Model)
xmm::SingleClassProbabilisticModel::SingleClassProbabilisticModel ( SingleClassProbabilisticModel const &  src)

Copy Constructor.

Parameters
srcSource Model
xmm::SingleClassProbabilisticModel::SingleClassProbabilisticModel ( std::shared_ptr< SharedParameters p,
Json::Value const &  root 
)
explicit

Constructor from Json.

Parameters
ppointer to a shared parameters object (owned by a Model)
rootJson structure
xmm::SingleClassProbabilisticModel::~SingleClassProbabilisticModel ( )
virtual

Destructor.

Member Function Documentation

std::string xmm::Writable::__str__ ( ) const
inlineinherited

"print" method for python => returns the results of write method

Warning
only defined if SWIGPYTHON is defined
virtual void xmm::SingleClassProbabilisticModel::allocate ( )
protectedpure virtual

Allocate memory for the model's parameters.

called when dimensions are modified

Implemented in xmm::SingleClassHMM, and xmm::SingleClassGMM.

void xmm::SingleClassProbabilisticModel::cancelTraining ( )

Cancels the training process : sets a flag so that the training stops at the next possible exit in the training process.

Warning
the model is still training when this function returns. This function only requests the training process to cancel.
bool xmm::SingleClassProbabilisticModel::cancelTrainingIfRequested ( )
protected

checks if a cancel request has been sent and accordingly cancels the training process

Returns
true if the training has been canceled.
void xmm::SingleClassProbabilisticModel::check_training ( ) const
inlineprotected

Checks if the model is still training.

Exceptions
runtime_errorif the model is training.
bool xmm::SingleClassProbabilisticModel::emAlgorithmHasConverged ( int  step,
double  log_prob,
double  old_log_prob 
) const
protected

checks if the training has converged according to the object's EM stop criterion

Parameters
stepindex of the current step of the EM algorithm
log_problog-likelihood returned by the EM update
old_log_problog-likelihood returned by the EM update at the previous step
virtual void xmm::SingleClassProbabilisticModel::emAlgorithmInit ( TrainingSet trainingSet)
protectedpure virtual

Initialize the training algorithm.

Implemented in xmm::SingleClassHMM, and xmm::SingleClassGMM.

void xmm::SingleClassProbabilisticModel::emAlgorithmTerminate ( )
protectedvirtual

Terminate the training algorithm.

Reimplemented in xmm::SingleClassHMM.

virtual double xmm::SingleClassProbabilisticModel::emAlgorithmUpdate ( TrainingSet trainingSet)
protectedpure virtual

Update Method of the EM algorithm.

performs E and M steps of the EM algorithm.

Returns
likelihood of the training data given the current model parameters (before re-estimation).

Implemented in xmm::SingleClassHMM, and xmm::SingleClassGMM.

virtual double xmm::SingleClassProbabilisticModel::filter ( std::vector< float > const &  observation)
pure virtual

filters a incoming observation (performs recognition or regression)

the results of the inference process are stored in the results attribute

Parameters
observationobservation vector
Returns
likelihood of the observation

Implemented in xmm::SingleClassHMM, and xmm::SingleClassGMM.

virtual void xmm::SingleClassProbabilisticModel::fromJson ( Json::Value const &  root)
pure virtual

Read the object from a JSON Structure.

Parameters
rootJSON value containing the object's information
Exceptions
JsonExceptionif the JSON value has a wrong format

Implements xmm::Writable.

Implemented in xmm::SingleClassHMM, and xmm::SingleClassGMM.

bool xmm::SingleClassProbabilisticModel::isTraining ( ) const

Checks if the model is training.

Returns
true if the model is training
xmm::SingleClassProbabilisticModel & xmm::SingleClassProbabilisticModel::operator= ( SingleClassProbabilisticModel const &  src)

Assignment.

Parameters
srcSource Model
void xmm::Writable::readFile ( char *  fileName)
inlineinherited

read method for python wrapping ('read' keyword forbidden, name has to be different)

Warning
only defined if SWIGPYTHON is defined
void xmm::SingleClassProbabilisticModel::reset ( )
virtual

Resets the fitering process (recognition or regression)

Reimplemented in xmm::SingleClassHMM, and xmm::SingleClassGMM.

Json::Value xmm::SingleClassProbabilisticModel::toJson ( ) const
virtual

Write the object to a JSON Structure.

Returns
Json value containing the object's information

Implements xmm::Writable.

Reimplemented in xmm::SingleClassHMM, and xmm::SingleClassGMM.

void xmm::SingleClassProbabilisticModel::train ( TrainingSet trainingSet)

Main training method based on the EM algorithm.

the method performs a loop over the pure virtual method emAlgorithmUpdate() until convergence. The emAlgorithmUpdate method computes both E and M steps of the EM algorithm.

Parameters
trainingSetTraining Set to train the model.
See also
emAlgorithmUpdate
void xmm::Writable::writeFile ( char *  fileName) const
inlineinherited

write method for python wrapping ('write' keyword forbidden, name has to be different)

Warning
only defined if SWIGPYTHON is defined

Member Data Documentation

bool xmm::SingleClassProbabilisticModel::cancel_training_
protected

defines if the model received a request to cancel training

bool xmm::SingleClassProbabilisticModel::is_training_
protected

defines if the model is being trained.

std::string xmm::SingleClassProbabilisticModel::label

label associated with the given model

CircularBuffer<double> xmm::SingleClassProbabilisticModel::likelihood_buffer_
protected

Likelihood buffer used for smoothing.

std::shared_ptr<SharedParameters> xmm::SingleClassProbabilisticModel::shared_parameters

Pointer to the shared parameters owned by a multi-class model.

EventGenerator<TrainingEvent> xmm::SingleClassProbabilisticModel::training_events

Generator for events monitoring the training process.

std::mutex xmm::SingleClassProbabilisticModel::training_mutex_
protected

Mutex used in Concurrent Mode.

TrainingEvent xmm::SingleClassProbabilisticModel::training_status

Event containing information on the current status of the training process.


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