Base class for the definition of training sets. More...
#include <xmmTrainingSet.hpp>
Public Member Functions | |
TrainingSet (MemoryMode memoryMode=MemoryMode::OwnMemory, Multimodality multimodality=Multimodality::Unimodal) | |
Constructor. More... | |
TrainingSet (TrainingSet const &src) | |
Copy Constructor. More... | |
TrainingSet (Json::Value const &root) | |
Constructor from Json Structure. More... | |
TrainingSet & | operator= (TrainingSet const &src) |
Assignment Operator. More... | |
virtual | ~TrainingSet () |
Destructor. More... | |
Accessors | |
bool | ownMemory () const |
checks if the training set is owns the data More... | |
bool | bimodal () const |
checks if the training set is bimodal More... | |
Manipulate Phrases | |
bool | empty () const |
checks if the training set is empty More... | |
unsigned int | size () const |
Size of the training set. More... | |
std::map< int, std::shared_ptr< xmm::Phrase > >::iterator | begin () |
iterator to the beginning of phrases More... | |
std::map< int, std::shared_ptr< xmm::Phrase > >::iterator | end () |
iterator to the end of phrases More... | |
std::map< int, std::shared_ptr< xmm::Phrase > >::reverse_iterator | rbegin () |
reverse iterator to the beginning of phrases More... | |
std::map< int, std::shared_ptr< xmm::Phrase > >::reverse_iterator | rend () |
reverse iterator to the end of phrases More... | |
std::map< int, std::shared_ptr< xmm::Phrase > >::const_iterator | cbegin () const |
constant iterator to the beginning of phrases More... | |
std::map< int, std::shared_ptr< xmm::Phrase > >::const_iterator | cend () const |
constant iterator to the end of phrases More... | |
std::map< int, std::shared_ptr< xmm::Phrase > >::const_reverse_iterator | crbegin () const |
constant reverse iterator to the beginning of phrases More... | |
std::map< int, std::shared_ptr< xmm::Phrase > >::const_reverse_iterator | crend () const |
constant reverse iterator to the end of phrases More... | |
void | addPhrase (int phraseIndex, std::string label="") |
add a new phrase, or reset the phrase if existing More... | |
void | addPhrase (int phraseIndex, Phrase const &phrase) |
add a new phrase, or reset the phrase if existing More... | |
void | addPhrase (int phraseIndex, std::shared_ptr< Phrase > phrase) |
add a new phrase, or reset the phrase if existing More... | |
void | removePhrase (int phraseIndex) |
delete a phrase More... | |
void | removePhrasesOfClass (std::string const &label) |
delete all phrases of a given class More... | |
std::shared_ptr< xmm::Phrase > | getPhrase (int phraseIndex) const |
Access Phrase by index. More... | |
TrainingSet * | getPhrasesOfClass (std::string const &label) |
get the pointer to the sub-training set containing all phrases with a given label More... | |
void | clear () |
delete all phrases More... | |
const std::set< std::string > & | labels () const |
get the list of labels currently in the training set 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... | |
Utilities | |
std::vector< float > | mean () const |
Compute the global mean of all data phrases along the time axis. More... | |
std::vector< float > | standardDeviation () const |
Compute the global standard deviation of all data phrases along the time axis. More... | |
std::vector< std::pair< float, float > > | minmax () const |
Compute the global min/max of all data phrases along the time axis. More... | |
void | rescale (std::vector< float > offset, std::vector< float > gain) |
rescale a phrase given an offset and gain More... | |
void | normalize () |
normalize the training set by rescaling all phrases to the mean/std of the whole training set 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 | |
Attribute< unsigned int > | dimension |
total dimension of the training data More... | |
Attribute< unsigned int > | dimension_input |
dimension of the input modality in bimodal mode More... | |
Attribute< std::vector< std::string > > | column_names |
labels of the columns of the training set (e.g. descriptor names) More... | |
Protected Member Functions | |
void | onPhraseEvent (PhraseEvent const &e) |
Monitors the training of each Model of the group. More... | |
virtual void | onAttributeChange (AttributeBase *attr_pointer) |
notification function called when a member attribute is changed More... | |
virtual void | update () |
create all the sub-training sets: one for each label More... | |
Protected Attributes | |
bool | own_memory_ |
defines if the phrase has its own memory More... | |
bool | bimodal_ |
defines if the phrase is bimodal More... | |
std::set< std::string > | labels_ |
Set containing all the labels present in the training set. More... | |
std::map< int, std::shared_ptr< Phrase > > | phrases_ |
Training Phrases. More... | |
std::map< std::string, TrainingSet > | sub_training_sets_ |
Sub-ensembles of the training set for specific classes. More... | |
Base class for the definition of training sets.
Training sets host a collection of phrases
xmm::TrainingSet::TrainingSet | ( | MemoryMode | memoryMode = MemoryMode::OwnMemory , |
Multimodality | multimodality = Multimodality::Unimodal |
||
) |
Constructor.
memoryMode | Memory mode (owned vs shared) |
multimodality | Number of modalities |
xmm::TrainingSet::TrainingSet | ( | TrainingSet const & | src | ) |
Copy Constructor.
src | source Training Set |
|
explicit |
Constructor from Json Structure.
root | Json Value |
|
virtual |
Destructor.
|
inlineinherited |
"print" method for python => returns the results of write method
void xmm::TrainingSet::addPhrase | ( | int | phraseIndex, |
std::string | label = "" |
||
) |
add a new phrase, or reset the phrase if existing
The phrase is set to an empty phrase with the current attributes (dimensions, etc). The phrase is created if it does not exists at the given index.
phraseIndex | index of the data phrase in the trainingSet |
label | Label of the phrase |
void xmm::TrainingSet::addPhrase | ( | int | phraseIndex, |
Phrase const & | phrase | ||
) |
add a new phrase, or reset the phrase if existing
The phrase is set to a copy of the phrase passed in argument The phrase is created if it does not exists at the given index.
phraseIndex | index of the data phrase in the trainingSet |
phrase | source phrase |
void xmm::TrainingSet::addPhrase | ( | int | phraseIndex, |
std::shared_ptr< Phrase > | phrase | ||
) |
add a new phrase, or reset the phrase if existing
The phrase is set to point to the existing phrase passed in argument. The phrase is created if it does not exists at the given index.
phraseIndex | index of the data phrase in the trainingSet |
phrase | pointer to an existing phrase |
std::map< int, std::shared_ptr< xmm::Phrase > >::iterator xmm::TrainingSet::begin | ( | ) |
iterator to the beginning of phrases
bool xmm::TrainingSet::bimodal | ( | ) | const |
checks if the training set is bimodal
std::map< int, std::shared_ptr< xmm::Phrase > >::const_iterator xmm::TrainingSet::cbegin | ( | ) | const |
constant iterator to the beginning of phrases
std::map< int, std::shared_ptr< xmm::Phrase > >::const_iterator xmm::TrainingSet::cend | ( | ) | const |
constant iterator to the end of phrases
void xmm::TrainingSet::clear | ( | ) |
delete all phrases
std::map< int, std::shared_ptr< xmm::Phrase > >::const_reverse_iterator xmm::TrainingSet::crbegin | ( | ) | const |
constant reverse iterator to the beginning of phrases
std::map< int, std::shared_ptr< xmm::Phrase > >::const_reverse_iterator xmm::TrainingSet::crend | ( | ) | const |
constant reverse iterator to the end of phrases
bool xmm::TrainingSet::empty | ( | ) | const |
checks if the training set is empty
std::map< int, std::shared_ptr< xmm::Phrase > >::iterator xmm::TrainingSet::end | ( | ) |
iterator to the end of phrases
|
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.
std::shared_ptr< xmm::Phrase > xmm::TrainingSet::getPhrase | ( | int | phraseIndex | ) | const |
Access Phrase by index.
phraseIndex | index of the phrase |
xmm::TrainingSet * xmm::TrainingSet::getPhrasesOfClass | ( | std::string const & | label | ) |
get the pointer to the sub-training set containing all phrases with a given label
label | target label |
out_of_range | if the label does not exist |
|
inline |
get the list of labels currently in the training set
std::vector< float > xmm::TrainingSet::mean | ( | ) | const |
Compute the global mean of all data phrases along the time axis.
std::vector< std::pair< float, float > > xmm::TrainingSet::minmax | ( | ) | const |
Compute the global min/max of all data phrases along the time axis.
void xmm::TrainingSet::normalize | ( | ) |
normalize the training set by rescaling all phrases to the mean/std of the whole training set
|
protectedvirtual |
notification function called when a member attribute is changed
|
protected |
Monitors the training of each Model of the group.
xmm::TrainingSet & xmm::TrainingSet::operator= | ( | TrainingSet const & | src | ) |
Assignment Operator.
src | source Training Set |
bool xmm::TrainingSet::ownMemory | ( | ) | const |
checks if the training set is owns the data
std::map< int, std::shared_ptr< xmm::Phrase > >::reverse_iterator xmm::TrainingSet::rbegin | ( | ) |
reverse iterator to the beginning of phrases
|
inlineinherited |
read method for python wrapping ('read' keyword forbidden, name has to be different)
void xmm::TrainingSet::removePhrase | ( | int | phraseIndex | ) |
delete a phrase
phraseIndex | index of the phrase |
out_of_bounds | if the phrase does not exist |
void xmm::TrainingSet::removePhrasesOfClass | ( | std::string const & | label | ) |
delete all phrases of a given class
label | label of the class to delete |
out_of_bounds | if the label does not exist |
std::map< int, std::shared_ptr< xmm::Phrase > >::reverse_iterator xmm::TrainingSet::rend | ( | ) |
reverse iterator to the end of phrases
void xmm::TrainingSet::rescale | ( | std::vector< float > | offset, |
std::vector< float > | gain | ||
) |
rescale a phrase given an offset and gain
offset | constant offset to be subtracted |
gain | gain to be applied |
unsigned int xmm::TrainingSet::size | ( | ) | const |
Size of the training set.
std::vector< float > xmm::TrainingSet::standardDeviation | ( | ) | const |
Compute the global standard deviation of all data phrases along the time axis.
|
virtual |
Write the object to a JSON Structure.
Implements xmm::Writable.
|
protectedvirtual |
create all the sub-training sets: one for each label
each subset contains only the phrase for the given label
|
inlineinherited |
write method for python wrapping ('write' keyword forbidden, name has to be different)
|
protected |
defines if the phrase is bimodal
Attribute<std::vector<std::string> > xmm::TrainingSet::column_names |
labels of the columns of the training set (e.g. descriptor names)
Attribute<unsigned int> xmm::TrainingSet::dimension |
total dimension of the training data
Attribute<unsigned int> xmm::TrainingSet::dimension_input |
dimension of the input modality in bimodal mode
|
protected |
Set containing all the labels present in the training set.
|
protected |
defines if the phrase has its own memory
|
protected |
Training Phrases.
Phrases are stored in a map: allows the easy addition/deletion of phrases by index.
|
protected |
Sub-ensembles of the training set for specific classes.