Single-Class Gaussian Mixture Model. More...
#include <xmmGmmSingleClass.hpp>
Public Member Functions | |
SingleClassGMM (std::shared_ptr< SharedParameters > p=NULL) | |
Constructor. More... | |
SingleClassGMM (SingleClassGMM const &src) | |
Copy constructor. More... | |
SingleClassGMM (std::shared_ptr< SharedParameters > p, Json::Value const &root) | |
Copy constructor. More... | |
SingleClassGMM & | operator= (SingleClassGMM const &src) |
Assignment. More... | |
Performance | |
void | reset () |
Resets the fitering process (recognition or regression) More... | |
double | filter (std::vector< float > const &observation) |
filters a incoming observation (performs recognition or regression) More... | |
Json I/O | |
Json::Value | toJson () const |
Write the object to a JSON Structure. More... | |
void | fromJson (Json::Value const &root) |
Read the object from a JSON Structure. 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... | |
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 | |
ClassParameters< GMM > | parameters |
Convert to bimodal GMM in place. More... | |
ClassResults< GMM > | results |
Results of the filtering process (recognition & regression) More... | |
std::vector< GaussianDistribution > | components |
Vector of Gaussian Components. More... | |
std::vector< float > | mixture_coeffs |
Mixture Coefficients. More... | |
std::vector< double > | beta |
Beta probabilities: likelihood of each component. More... | |
std::string | label |
label associated with the given model More... | |
std::shared_ptr< SharedParameters > | shared_parameters |
Pointer to the shared parameters owned by a multi-class model. More... | |
EventGenerator< TrainingEvent > | training_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 | |
void | allocate () |
Allocate model parameters. More... | |
double | obsProb (const float *observation, int mixtureComponent=-1) const |
Observation probability. More... | |
double | obsProb_input (const float *observation_input, int mixtureComponent=-1) const |
Observation probability on the input modality. More... | |
double | obsProb_bimodal (const float *observation_input, const float *observation_output, int mixtureComponent=-1) const |
Observation probability for bimodal mode. More... | |
void | emAlgorithmInit (TrainingSet *trainingSet) |
Initialize the EM Training Algorithm. More... | |
double | emAlgorithmUpdate (TrainingSet *trainingSet) |
Update Function of the EM algorithm. More... | |
void | initParametersToDefault (std::vector< float > const &dataStddev) |
Initialize model parameters to default values. More... | |
void | initMeansWithKMeans (TrainingSet *trainingSet) |
Initialize the means of the Gaussian components with a Biased K-means. More... | |
void | initCovariances_fullyObserved (TrainingSet *trainingSet) |
Initialize the Covariances of the Gaussian components using a fully observed approximation. More... | |
void | normalizeMixtureCoeffs () |
Normalize mixture coefficients. More... | |
void | addCovarianceOffset () |
Add offset to the diagonal of the covariance matrices. More... | |
void | updateInverseCovariances () |
Update inverse covariances of each Gaussian component. More... | |
double | likelihood (std::vector< float > const &observation, std::vector< float > const &observation_output=null_vector_float) |
Compute likelihood and estimate components probabilities. More... | |
void | regression (std::vector< float > const &observation_input) |
Compute Gaussian Mixture Regression. More... | |
void | updateResults () |
update the content of the likelihood buffer and return average likelihood. 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 | |
std::vector< double > | current_regularization |
vector containing the regularization values over each dimension More... | |
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... | |
Friends | |
template<typename SingleClassModel , typename ModelType > | |
class | Model |
class | SingleClassHMM |
class | HierarchicalHMM |
Single-Class Gaussian Mixture Model.
Multivariate Gaussian Mixture Model. Supports Bimodal data and Gaussian Mixture Regression. Can be either autonomous or a state of a HMM: defines observation probabilities for each state.
xmm::SingleClassGMM::SingleClassGMM | ( | std::shared_ptr< SharedParameters > | p = NULL | ) |
Constructor.
p | pointer to a shared parameters object (owned by a Model) |
xmm::SingleClassGMM::SingleClassGMM | ( | SingleClassGMM const & | src | ) |
Copy constructor.
src | Source GMM |
|
explicit |
Copy constructor.
p | pointer to a shared parameters object (owned by a Model) |
root | Json structure |
|
inlineinherited |
"print" method for python => returns the results of write method
|
protected |
Add offset to the diagonal of the covariance matrices.
Guarantees convergence through covariance matrix invertibility
|
protectedvirtual |
Allocate model parameters.
Implements xmm::SingleClassProbabilisticModel.
|
inherited |
Cancels the training process : sets a flag so that the training stops at the next possible exit in the training process.
|
protectedinherited |
checks if a cancel request has been sent and accordingly cancels the training process
|
inlineprotectedinherited |
Checks if the model is still training.
runtime_error | if the model is training. |
|
protectedinherited |
checks if the training has converged according to the object's EM stop criterion
step | index of the current step of the EM algorithm |
log_prob | log-likelihood returned by the EM update |
old_log_prob | log-likelihood returned by the EM update at the previous step |
|
protectedvirtual |
Initialize the EM Training Algorithm.
Initializes the Gaussian Components from the first phrase of the Training Set
Implements xmm::SingleClassProbabilisticModel.
|
protectedvirtualinherited |
Terminate the training algorithm.
Reimplemented in xmm::SingleClassHMM.
|
protectedvirtual |
Update Function of the EM algorithm.
Implements xmm::SingleClassProbabilisticModel.
|
virtual |
filters a incoming observation (performs recognition or regression)
the results of the inference process are stored in the results attribute
observation | observation vector |
Implements xmm::SingleClassProbabilisticModel.
|
virtual |
Read the object from a JSON Structure.
root | JSON value containing the object's information |
JsonException | if the JSON value has a wrong format |
Implements xmm::SingleClassProbabilisticModel.
|
protected |
Initialize the Covariances of the Gaussian components using a fully observed approximation.
|
protected |
Initialize the means of the Gaussian components with a Biased K-means.
|
protected |
Initialize model parameters to default values.
Mixture coefficients are then equiprobable
|
inherited |
Checks if the model is training.
|
protected |
Compute likelihood and estimate components probabilities.
If the model is bimodal, the likelihood is computed only on the input modality, except if 'observation_output' is specified. Updates the likelihood buffer used to smooth likelihoods.
observation | observation vector (full size for unimodal, input modality for bimodal) |
observation_output | observation vector of the output modality |
|
protected |
Normalize mixture coefficients.
|
protected |
Observation probability.
observation | observation vector (must be of size 'dimension') |
mixtureComponent | index of the mixture component. if unspecified or negative, full mixture observation probability is computed |
out_of_range | if the index of the Gaussian Mixture Component is out of bounds |
runtime_error | if the Covariance Matrix is not invertible |
|
protected |
Observation probability for bimodal mode.
observation_input | observation vector of the input modality (must be of size 'dimension_input') |
observation_output | observation vector of the input output (must be of size 'dimension - dimension_input') |
mixtureComponent | index of the mixture component. if unspecified or negative, full mixture observation probability is computed |
runtime_error | if the model is not bimodal |
runtime_error | if the Covariance Matrix is not invertible |
|
protected |
Observation probability on the input modality.
observation_input | observation vector of the input modality (must be of size 'dimension_input') |
mixtureComponent | index of the mixture component. if unspecified or negative, full mixture observation probability is computed |
runtime_error | if the model is not bimodal |
runtime_error | if the Covariance Matrix of the input modality is not invertible |
xmm::SingleClassGMM & xmm::SingleClassGMM::operator= | ( | SingleClassGMM const & | src | ) |
Assignment.
src | Source GMM |
|
inlineinherited |
read method for python wrapping ('read' keyword forbidden, name has to be different)
|
protected |
Compute Gaussian Mixture Regression.
Estimates the output modality using covariance-based regression weighted by components' likelihood
observation_input | observation vector of the input modality |
|
virtual |
Resets the fitering process (recognition or regression)
Reimplemented from xmm::SingleClassProbabilisticModel.
|
virtual |
Write the object to a JSON Structure.
Reimplemented from xmm::SingleClassProbabilisticModel.
|
inherited |
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.
trainingSet | Training Set to train the model. |
|
protected |
Update inverse covariances of each Gaussian component.
runtime_error | if one of the covariance matrices is not invertible |
|
protected |
update the content of the likelihood buffer and return average likelihood.
The method also updates the cumulative log-likelihood computed over a window (cumulativeloglikelihood)
|
inlineinherited |
write method for python wrapping ('write' keyword forbidden, name has to be different)
|
friend |
|
friend |
|
friend |
std::vector<double> xmm::SingleClassGMM::beta |
Beta probabilities: likelihood of each component.
|
protectedinherited |
defines if the model received a request to cancel training
std::vector<GaussianDistribution> xmm::SingleClassGMM::components |
Vector of Gaussian Components.
|
protected |
vector containing the regularization values over each dimension
computed by combining relative and absolute regularization with the training set
|
protectedinherited |
defines if the model is being trained.
|
inherited |
label associated with the given model
|
protectedinherited |
Likelihood buffer used for smoothing.
std::vector<float> xmm::SingleClassGMM::mixture_coeffs |
Mixture Coefficients.
ClassParameters<GMM> xmm::SingleClassGMM::parameters |
Convert to bimodal GMM in place.
dimension_input | dimension of the input modality |
runtime_error | if the model is already bimodal |
out_of_range | if the requested input dimension is too large Convert to unimodal GMM in place |
runtime_error | if the model is already unimodal extract a submodel with the given columns |
columns | columns indices in the target order |
runtime_error | if the model is training |
out_of_range | if the number or indices of the requested columns exceeds the current dimension |
runtime_error | if the model is training or if it is not bimodal |
runtime_error | if the model is training or if it is not bimodal |
runtime_error | if the model is training or if it is not bimodal |
ClassResults<GMM> xmm::SingleClassGMM::results |
Results of the filtering process (recognition & regression)
|
inherited |
Pointer to the shared parameters owned by a multi-class model.
|
inherited |
Generator for events monitoring the training process.
|
protectedinherited |
Mutex used in Concurrent Mode.
|
inherited |
Event containing information on the current status of the training process.