XMM - Probabilistic Models for Motion Recognition and Mapping

Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
xmm::KMeans Class Reference

K-Means Clustering algorithm. More...

#include <xmmKMeans.hpp>

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

Public Types

enum  InitializationMode { InitializationMode::Random, InitializationMode::Biased }
 Type of initizalization of the K-Means algorithm. More...
 

Public Member Functions

 KMeans (unsigned int clusters=1)
 Default Constructor. More...
 
 KMeans (KMeans const &src)
 Copy Constructor. More...
 
KMeansoperator= (KMeans const &src)
 Assignment. More...
 
void train (TrainingSet *trainingSet)
 Train the K-Means clutering from the given training set. More...
 
void reset ()
 Resets the fitering process (cluster association) More...
 
void filter (std::vector< float > const &observation)
 filters a incoming observation (performs cluster association) 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...
 
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...
 

Static Public Member Functions

static const float DEFAULT_RELATIVE_VARIATION_THRESHOLD ()
 

Public Attributes

std::shared_ptr< SharedParametersshared_parameters
 Set of Parameters shared among classes. More...
 
Configuration< KMeansconfiguration
 Configuration (default and class-specific parameters) More...
 
Results< KMeansresults
 Results of the cluster association after update with an observation. More...
 
std::vector< float > centers
 Clusters centers. More...
 
KMeans::InitializationMode initialization_mode
 Type of initialization for the K-Means Algorithm. More...
 

Static Public Attributes

static const unsigned int DEFAULT_MAX_ITERATIONS = 50
 

Protected Member Functions

void randomizeClusters (std::vector< float > const &trainingSetVariance)
 randomzie Cluster Centers (normalized width data variance) of the first phrase of the training set More...
 
void initClustersWithFirstPhrase (std::shared_ptr< Phrase > phrase)
 Initialize the clusters using a regular segmentation of the first phrase of the training set. More...
 
void updateCenters (std::vector< float > &previous_centers, TrainingSet *trainingSet)
 Update method for training. More...
 

Detailed Description

K-Means Clustering algorithm.

Member Enumeration Documentation

Type of initizalization of the K-Means algorithm.

Enumerator
Random 

random initialization (scaled using training set variance)

Biased 

biased initialization: initialiazed with the first phrase

Constructor & Destructor Documentation

xmm::KMeans::KMeans ( unsigned int  clusters = 1)

Default Constructor.

Parameters
clustersnumber of clusters
xmm::KMeans::KMeans ( KMeans const &  src)

Copy Constructor.

Parameters
srcSource Model

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
static const float xmm::KMeans::DEFAULT_RELATIVE_VARIATION_THRESHOLD ( )
inlinestatic
void xmm::KMeans::filter ( std::vector< float > const &  observation)

filters a incoming observation (performs cluster association)

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

Parameters
observationobservation vector
void xmm::KMeans::fromJson ( Json::Value const &  root)
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.

void xmm::KMeans::initClustersWithFirstPhrase ( std::shared_ptr< Phrase phrase)
protected

Initialize the clusters using a regular segmentation of the first phrase of the training set.

xmm::KMeans & xmm::KMeans::operator= ( KMeans const &  src)

Assignment.

Parameters
srcSource Model
void xmm::KMeans::randomizeClusters ( std::vector< float > const &  trainingSetVariance)
protected

randomzie Cluster Centers (normalized width data variance) of the first phrase of the training set

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::KMeans::reset ( )

Resets the fitering process (cluster association)

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

Write the object to a JSON Structure.

Returns
Json value containing the object's information

Implements xmm::Writable.

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

Train the K-Means clutering from the given training set.

Parameters
trainingSetTraining Set
void xmm::KMeans::updateCenters ( std::vector< float > &  previous_centers,
TrainingSet trainingSet 
)
protected

Update method for training.

computes the cluster associated with each data points, and update Cluster centers

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

std::vector<float> xmm::KMeans::centers

Clusters centers.

Configuration<KMeans> xmm::KMeans::configuration

Configuration (default and class-specific parameters)

const unsigned int xmm::KMeans::DEFAULT_MAX_ITERATIONS = 50
static
KMeans::InitializationMode xmm::KMeans::initialization_mode

Type of initialization for the K-Means Algorithm.

Results<KMeans> xmm::KMeans::results

Results of the cluster association after update with an observation.

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

Set of Parameters shared among classes.


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