33 #ifndef xmmTrainingSet_h 34 #define xmmTrainingSet_h 113 unsigned int size()
const;
118 std::map<int, std::shared_ptr<xmm::Phrase>>::iterator
begin();
123 std::map<int, std::shared_ptr<xmm::Phrase>>::iterator
end();
128 std::map<int, std::shared_ptr<xmm::Phrase>>::reverse_iterator
rbegin();
133 std::map<int, std::shared_ptr<xmm::Phrase>>::reverse_iterator
rend();
138 std::map<int, std::shared_ptr<xmm::Phrase>>::const_iterator
cbegin()
const;
143 std::map<int, std::shared_ptr<xmm::Phrase>>::const_iterator
cend()
const;
148 std::map<int, std::shared_ptr<xmm::Phrase>>::const_reverse_iterator
154 std::map<int, std::shared_ptr<xmm::Phrase>>::const_reverse_iterator
crend()
165 void addPhrase(
int phraseIndex, std::string label =
"");
184 void addPhrase(
int phraseIndex, std::shared_ptr<Phrase> phrase);
209 std::shared_ptr<xmm::Phrase>
getPhrase(
int phraseIndex)
const;
245 Json::Value
toJson()
const;
252 void fromJson(Json::Value
const& root);
263 std::vector<float>
mean()
const;
278 std::vector<std::pair<float, float>>
minmax()
const;
285 void rescale(std::vector<float> offset, std::vector<float> gain);
std::map< int, std::shared_ptr< xmm::Phrase > >::const_iterator cend() const
constant iterator to the end of phrases
Definition: xmmTrainingSet.cpp:202
Data phrase.
Definition: xmmPhrase.hpp:133
std::map< int, std::shared_ptr< Phrase > > phrases_
Training Phrases.
Definition: xmmTrainingSet.hpp:347
std::vector< float > mean() const
Compute the global mean of all data phrases along the time axis.
Definition: xmmTrainingSet.cpp:315
std::map< int, std::shared_ptr< xmm::Phrase > >::reverse_iterator rbegin()
reverse iterator to the beginning of phrases
Definition: xmmTrainingSet.cpp:187
std::map< int, std::shared_ptr< xmm::Phrase > >::const_iterator cbegin() const
constant iterator to the beginning of phrases
Definition: xmmTrainingSet.cpp:197
bool ownMemory() const
checks if the training set is owns the data
Definition: xmmTrainingSet.cpp:132
Multimodality
Number of modalities in the data phrase.
Definition: xmmPhrase.hpp:68
Attribute< unsigned int > dimension
total dimension of the training data
Definition: xmmTrainingSet.hpp:298
std::shared_ptr< xmm::Phrase > getPhrase(int phraseIndex) const
Access Phrase by index.
Definition: xmmTrainingSet.cpp:216
TrainingSet & operator=(TrainingSet const &src)
Assignment Operator.
Definition: xmmTrainingSet.cpp:105
std::set< std::string > labels_
Set containing all the labels present in the training set.
Definition: xmmTrainingSet.hpp:340
void clear()
delete all phrases
Definition: xmmTrainingSet.cpp:270
std::vector< float > standardDeviation() const
Compute the global standard deviation of all data phrases along the time axis.
Definition: xmmTrainingSet.cpp:333
void onPhraseEvent(PhraseEvent const &e)
Monitors the training of each Model of the group.
Definition: xmmTrainingSet.cpp:284
std::map< int, std::shared_ptr< xmm::Phrase > >::reverse_iterator rend()
reverse iterator to the end of phrases
Definition: xmmTrainingSet.cpp:192
virtual void onAttributeChange(AttributeBase *attr_pointer)
notification function called when a member attribute is changed
Definition: xmmTrainingSet.cpp:142
void normalize()
normalize the training set by rescaling all phrases to the mean/std of the whole training set ...
Definition: xmmTrainingSet.cpp:401
void rescale(std::vector< float > offset, std::vector< float > gain)
rescale a phrase given an offset and gain
Definition: xmmTrainingSet.cpp:394
std::map< int, std::shared_ptr< xmm::Phrase > >::const_reverse_iterator crbegin() const
constant reverse iterator to the beginning of phrases
Definition: xmmTrainingSet.cpp:207
void removePhrase(int phraseIndex)
delete a phrase
Definition: xmmTrainingSet.cpp:250
std::map< int, std::shared_ptr< xmm::Phrase > >::iterator end()
iterator to the end of phrases
Definition: xmmTrainingSet.cpp:182
bool empty() const
checks if the training set is empty
Definition: xmmTrainingSet.cpp:136
TrainingSet * getPhrasesOfClass(std::string const &label)
get the pointer to the sub-training set containing all phrases with a given label ...
Definition: xmmTrainingSet.cpp:276
Base Class for Generic Attributes.
Definition: xmmAttribute.hpp:105
unsigned int size() const
Size of the training set.
Definition: xmmTrainingSet.cpp:138
std::vector< std::pair< float, float > > minmax() const
Compute the global min/max of all data phrases along the time axis.
Definition: xmmTrainingSet.cpp:355
Json::Value toJson() const
Write the object to a JSON Structure.
Definition: xmmTrainingSet.cpp:408
const std::set< std::string > & labels() const
get the list of labels currently in the training set
Definition: xmmTrainingSet.hpp:234
bool bimodal_
defines if the phrase is bimodal
Definition: xmmTrainingSet.hpp:335
void fromJson(Json::Value const &root)
Read the object from a JSON Structure.
Definition: xmmTrainingSet.cpp:428
Base class for the definition of training sets.
Definition: xmmTrainingSet.hpp:46
Attribute< std::vector< std::string > > column_names
labels of the columns of the training set (e.g. descriptor names)
Definition: xmmTrainingSet.hpp:308
Abstract class for handling JSON + File I/O.
Definition: xmmJson.hpp:50
void addPhrase(int phraseIndex, std::string label="")
add a new phrase, or reset the phrase if existing
Definition: xmmTrainingSet.cpp:221
virtual void update()
create all the sub-training sets: one for each label
Definition: xmmTrainingSet.cpp:290
std::map< int, std::shared_ptr< xmm::Phrase > >::const_reverse_iterator crend() const
constant reverse iterator to the end of phrases
Definition: xmmTrainingSet.cpp:212
void removePhrasesOfClass(std::string const &label)
delete all phrases of a given class
Definition: xmmTrainingSet.cpp:255
Event that can be thrown by a phrase to a training set.
Definition: xmmPhrase.hpp:88
Definition: xmmAttribute.hpp:42
std::map< int, std::shared_ptr< xmm::Phrase > >::iterator begin()
iterator to the beginning of phrases
Definition: xmmTrainingSet.cpp:178
std::map< std::string, TrainingSet > sub_training_sets_
Sub-ensembles of the training set for specific classes.
Definition: xmmTrainingSet.hpp:352
TrainingSet(MemoryMode memoryMode=MemoryMode::OwnMemory, Multimodality multimodality=Multimodality::Unimodal)
Constructor.
Definition: xmmTrainingSet.cpp:35
bool bimodal() const
checks if the training set is bimodal
Definition: xmmTrainingSet.cpp:134
single modality (i.e. 1 data array)
MemoryMode
Type of memory management for training sets and phrases.
Definition: xmmPhrase.hpp:50
Attribute< unsigned int > dimension_input
dimension of the input modality in bimodal mode
Definition: xmmTrainingSet.hpp:303
virtual ~TrainingSet()
Destructor.
Definition: xmmTrainingSet.cpp:130
bool own_memory_
defines if the phrase has its own memory
Definition: xmmTrainingSet.hpp:330
memory is owned by the Phrase container.