K-Means Clustering algorithm. More...
#include <xmmKMeans.hpp>
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... | |
KMeans & | operator= (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< SharedParameters > | shared_parameters |
Set of Parameters shared among classes. More... | |
Configuration< KMeans > | configuration |
Configuration (default and class-specific parameters) More... | |
Results< KMeans > | results |
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... | |
K-Means Clustering algorithm.
|
strong |
xmm::KMeans::KMeans | ( | unsigned int | clusters = 1 | ) |
Default Constructor.
clusters | number of clusters |
xmm::KMeans::KMeans | ( | KMeans const & | src | ) |
Copy Constructor.
src | Source Model |
|
inlineinherited |
"print" method for python => returns the results of write method
|
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
observation | observation vector |
|
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::Writable.
|
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.
src | Source Model |
|
protected |
randomzie Cluster Centers (normalized width data variance) of the first phrase of the training set
|
inlineinherited |
read method for python wrapping ('read' keyword forbidden, name has to be different)
void xmm::KMeans::reset | ( | ) |
Resets the fitering process (cluster association)
|
virtual |
Write the object to a JSON Structure.
Implements xmm::Writable.
void xmm::KMeans::train | ( | TrainingSet * | trainingSet | ) |
Train the K-Means clutering from the given training set.
trainingSet | Training Set |
|
protected |
Update method for training.
computes the cluster associated with each data points, and update Cluster centers
|
inlineinherited |
write method for python wrapping ('write' keyword forbidden, name has to be different)
std::vector<float> xmm::KMeans::centers |
Clusters centers.
Configuration<KMeans> xmm::KMeans::configuration |
Configuration (default and class-specific parameters)
|
static |
KMeans::InitializationMode xmm::KMeans::initialization_mode |
Type of initialization for the K-Means Algorithm.
Results of the cluster association after update with an observation.
std::shared_ptr<SharedParameters> xmm::KMeans::shared_parameters |
Set of Parameters shared among classes.