![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
The databases' cell translators for continuous variables. More...
#include <agrum/base/database/DBTranslator4ContinuousVariable.h>
Public Member Functions | |
Constructors / Destructors | |
| DBTranslator4ContinuousVariable (const std::vector< std::string > &missing_symbols, const bool fit_range=false) | |
| default constructor without any initial variable | |
| DBTranslator4ContinuousVariable (const bool fit_range=false) | |
| default constructor without any initial variable nor missing symbol | |
| template<typename GUM_SCALAR> | |
| DBTranslator4ContinuousVariable (const ContinuousVariable< GUM_SCALAR > &var, const std::vector< std::string > &missing_symbols, const bool fit_range=false) | |
| default constructor with a continuous variable as translator | |
| template<typename GUM_SCALAR> | |
| DBTranslator4ContinuousVariable (const ContinuousVariable< GUM_SCALAR > &var, const bool fit_range=false) | |
| default constructor with a continuous variable as translator but without missing symbol | |
| DBTranslator4ContinuousVariable (const IContinuousVariable &var, const std::vector< std::string > &missing_symbols, const bool fit_range=false) | |
| default constructor with a IContinuous variable as translator | |
| DBTranslator4ContinuousVariable (const IContinuousVariable &var, const bool fit_range=false) | |
| default constructor with a IContinuous variable as translator but without missing symbol | |
| DBTranslator4ContinuousVariable (const DBTranslator4ContinuousVariable &from) | |
| copy constructor | |
| DBTranslator4ContinuousVariable (DBTranslator4ContinuousVariable &&from) | |
| move constructor | |
| virtual DBTranslator4ContinuousVariable * | clone () const |
| virtual copy constructor | |
| virtual | ~DBTranslator4ContinuousVariable () |
| destructor | |
Operators | |
| DBTranslator4ContinuousVariable & | operator= (const DBTranslator4ContinuousVariable &from) |
| copy operator | |
| DBTranslator4ContinuousVariable & | operator= (DBTranslator4ContinuousVariable &&from) |
| move operator | |
Accessors / Modifiers | |
| virtual DBTranslatedValue | translate (const std::string &str) final |
| returns the translation of a string | |
| virtual std::string | translateBack (const DBTranslatedValue translated_val) const final |
| returns the original value for a given translation | |
| virtual std::size_t | domainSize () const final |
| returns std::numeric_limits<std::size_t>::max () | |
| virtual bool | needsReordering () const final |
| indicates that the translations should never be reordered | |
| virtual HashTable< std::size_t, std::size_t > | reorder () final |
| returns an empty mapping, indicating that old tanslations are equal to the newly reordered ones. | |
| virtual const IContinuousVariable * | variable () const final |
| returns the variable stored into the translator | |
| virtual DBTranslatedValue | missingValue () const final |
| returns the translation of a missing value | |
Operators | |
| DBTranslatedValue | operator<< (const std::string &str) |
| alias for method translate | |
| std::string | operator>> (const DBTranslatedValue translated_val) |
| alias for method translateBack | |
Accessors / Modifiers | |
| virtual bool | hasEditableDictionary () const |
| indicates whether the translator has an editable dictionary or not | |
| virtual void | setEditableDictionaryMode (bool new_mode) |
| sets/unset the editable dictionary mode | |
| virtual const Bijection< std::size_t, std::string > & | getDictionary () const |
| returns the translation from database indices to input strings | |
| const Set< std::string > & | missingSymbols () const |
| returns the set of missing symbols taken into account by the translator | |
| bool | isMissingSymbol (const std::string &str) const |
| indicates whether a string corresponds to a missing symbol | |
| void | setVariableName (const std::string &str) const |
| sets the name of the variable stored into the translator | |
| void | setVariableDescription (const std::string &str) const |
| sets the name of the variable stored into the translator | |
| DBTranslatedValueType | getValType () const |
| returns the type of values handled by the translator | |
| bool | isLossless () const |
| returns a Boolean indicating whether the translation is lossless or not | |
| bool | isMissingValue (const DBTranslatedValue &val) const |
| indicates whether a translated value corresponds to a missing value | |
Protected Attributes | |
| bool | is_lossless_ |
| indicates whether the translation is lossless (e.g., ranges) or not | |
| bool | is_dictionary_dynamic_ |
| indicates whether the dictionary can be updated or not | |
| std::size_t | max_dico_entries_ |
| the maximum number of entries that the dictionary is allowed to contain | |
| Set< std::string > | missing_symbols_ |
| the set of missing symbols | |
| Bijection< std::size_t, std::string > | back_dico_ |
| the bijection relating back translated values and their original strings. | |
| DBTranslatedValueType | val_type_ |
| the type of the values translated by the translator | |
The databases' cell translators for continuous variables.
Translators are used by DatabaseTable instances to transform datasets' strings into DBTranslatedValue instances. The point is that strings are not adequate for fast learning, they need to be preprocessed into a type that can be analyzed quickly (the so-called DBTranslatedValue type).
A DBTranslator4ContinuousVariable is a translator that contains and exploits a ContinuousVariable for translations. Each time a string needs be translated, we ask the ContinuousVariable whether it belongs to its domain (which is supposed to be of type [x_min,x_max]). If this is the case, then the DBTranslatedValue corresponding to the translation of the string contains the floating point number specified in the string.
Definition at line 144 of file DBTranslator4ContinuousVariable.h.
| gum::learning::DBTranslator4ContinuousVariable::DBTranslator4ContinuousVariable | ( | const std::vector< std::string > & | missing_symbols, |
| const bool | fit_range = false ) |
default constructor without any initial variable
When using this constructor, it is assumed implicitly that the continuous variable has a range from minus infinity to plus infinity. If the fit_range parameter is on, the range of the variable is updated so that it precisely fits the range of the observed values in the database.
| missing_symbols | the set of symbols in the database representing missing values |
| fit_range | if true, the range of the variable is updated so that it precisely fits the range of the observed values in the database, else the range is kept to (-inf,inf) |
Referenced by DBTranslator4ContinuousVariable(), DBTranslator4ContinuousVariable(), clone(), operator=(), and operator=().
| gum::learning::DBTranslator4ContinuousVariable::DBTranslator4ContinuousVariable | ( | const bool | fit_range = false | ) |
default constructor without any initial variable nor missing symbol
When using this constructor, it is assumed implicitly that the continuous variable has a range from minus infinity to plus infinity. If the fit_range parameter is on, the range of the variable is updated so that it precisely fits the range of the observed values in the database.
| fit_range | if true, the range of the variable is updated so that it precisely fits the range of the observed values in the database, else the range is kept to (-inf,inf) |
| gum::learning::DBTranslator4ContinuousVariable::DBTranslator4ContinuousVariable | ( | const ContinuousVariable< GUM_SCALAR > & | var, |
| const std::vector< std::string > & | missing_symbols, | ||
| const bool | fit_range = false ) |
default constructor with a continuous variable as translator
| var | a continuous variable that will be used for translations. The translator keeps a copy of this variable |
| missing_symbols | the set of symbols in the database representing missing values |
| fit_range | if true, the range of the variable is updated so that it precisely fits the range of the observed values in the database, else the range is kept to (-inf,inf) |
| gum::learning::DBTranslator4ContinuousVariable::DBTranslator4ContinuousVariable | ( | const ContinuousVariable< GUM_SCALAR > & | var, |
| const bool | fit_range = false ) |
default constructor with a continuous variable as translator but without missing symbol
| var | a continuous variable that will be used for translations. The translator keeps a copy of this variable |
| fit_range | if true, the range of the variable is updated so that it precisely fits the range of the observed values in the database, else the range is kept to (-inf,inf) |
| gum::learning::DBTranslator4ContinuousVariable::DBTranslator4ContinuousVariable | ( | const IContinuousVariable & | var, |
| const std::vector< std::string > & | missing_symbols, | ||
| const bool | fit_range = false ) |
default constructor with a IContinuous variable as translator
| var | a IContinuous variable that will be used for translations. The translator keeps a copy of this variable |
| missing_symbols | the set of symbols in the database representing missing values |
| fit_range | if true, the range of the variable is updated so that it precisely fits the range of the observed values in the database, else the range is kept to (-inf,inf) |
| gum::learning::DBTranslator4ContinuousVariable::DBTranslator4ContinuousVariable | ( | const IContinuousVariable & | var, |
| const bool | fit_range = false ) |
default constructor with a IContinuous variable as translator but without missing symbol
| var | a IContinuous variable that will be used for translations. The translator keeps a copy of this variable |
| fit_range | if true, the range of the variable is updated so that it precisely fits the range of the observed values in the database, else the range is kept to (-inf,inf) |
| gum::learning::DBTranslator4ContinuousVariable::DBTranslator4ContinuousVariable | ( | const DBTranslator4ContinuousVariable & | from | ) |
copy constructor
References DBTranslator4ContinuousVariable().
| gum::learning::DBTranslator4ContinuousVariable::DBTranslator4ContinuousVariable | ( | DBTranslator4ContinuousVariable && | from | ) |
move constructor
References DBTranslator4ContinuousVariable().
|
virtual |
destructor
|
virtual |
virtual copy constructor
Implements gum::learning::DBTranslator.
References DBTranslator4ContinuousVariable().
|
finalvirtual |
returns std::numeric_limits<std::size_t>::max ()
Implements gum::learning::DBTranslator.
|
virtualinherited |
returns the translation from database indices to input strings
|
inherited |
returns the type of values handled by the translator
Referenced by gum::learning::BNDatabaseGenerator< GUM_SCALAR >::toDatabaseTable().
|
virtualinherited |
indicates whether the translator has an editable dictionary or not
Reimplemented in gum::learning::DBTranslator4DiscretizedVariable, gum::learning::DBTranslator4IntegerVariable, and gum::learning::DBTranslator4NumericalDiscreteVariable.
|
inherited |
returns a Boolean indicating whether the translation is lossless or not
Some translations can lose some information. For instance, a translator for a discretized variable will translate all the values of a discretization interval as the same value (the index of the interval). As such it looses some information because, knowing this index, it is impossible to get back to the original value that was translated. Method isLossless() indicates whether the translation never loses any information or not.
|
inherited |
indicates whether a string corresponds to a missing symbol
|
inherited |
indicates whether a translated value corresponds to a missing value
|
inherited |
returns the set of missing symbols taken into account by the translator
|
finalvirtual |
returns the translation of a missing value
Implements gum::learning::DBTranslator.
References missingValue().
Referenced by missingValue().
|
finalvirtual |
indicates that the translations should never be reordered
Implements gum::learning::DBTranslator.
References needsReordering().
Referenced by needsReordering().
|
inherited |
alias for method translate
| DBTranslator4ContinuousVariable & gum::learning::DBTranslator4ContinuousVariable::operator= | ( | const DBTranslator4ContinuousVariable & | from | ) |
copy operator
References DBTranslator4ContinuousVariable().
| DBTranslator4ContinuousVariable & gum::learning::DBTranslator4ContinuousVariable::operator= | ( | DBTranslator4ContinuousVariable && | from | ) |
move operator
References DBTranslator4ContinuousVariable().
|
inherited |
alias for method translateBack
|
finalvirtual |
returns an empty mapping, indicating that old tanslations are equal to the newly reordered ones.
Implements gum::learning::DBTranslator.
References reorder().
Referenced by reorder().
|
virtualinherited |
sets/unset the editable dictionary mode
Reimplemented in gum::learning::DBTranslator4DiscretizedVariable, gum::learning::DBTranslator4IntegerVariable, and gum::learning::DBTranslator4NumericalDiscreteVariable.
|
inherited |
sets the name of the variable stored into the translator
|
inherited |
sets the name of the variable stored into the translator
|
finalvirtual |
returns the translation of a string
This method tries to translate a given string into the DBTranslatedValue that should be stored into a DatabaseTable. If the translator cannot find the translation in its current dictionary, then two situations can obtain:
| UnknownLabelInDatabase | is raised if the number represented by the string is out of the range of the continuous variable and the translator is not in an editable dictionary mode. |
| OperationNotAllowed | exception is raised if the translation cannot be found and the insertion of the string into the translator's dictionary fails because it would induce incoherent behavior (e.g., a DBTranslator4ContinuousVariable that contains a variable whose domain is [x,y] as well as a missing value symbol z \(\in\) [x,y]). |
| TypeError | is raised if the translation cannot be found and the insertion of the string into the translator's dictionary fails due to str being impossible to be converted into an appropriate type. |
Implements gum::learning::DBTranslator.
|
finalvirtual |
returns the original value for a given translation
| UnknownLabelInDatabase | is raised if this original value is outside the domain of the continuous variable stored within the translator |
Implements gum::learning::DBTranslator.
|
finalvirtual |
returns the variable stored into the translator
Implements gum::learning::DBTranslator.
References variable().
Referenced by variable().
|
mutableprotectedinherited |
the bijection relating back translated values and their original strings.
Note that the translated values considered here are of type std::size_t because only the values for discrete variables need be stored, those for continuous variables are actually identity mappings.
Definition at line 399 of file DBTranslator.h.
|
protectedinherited |
indicates whether the dictionary can be updated or not
Definition at line 385 of file DBTranslator.h.
|
protectedinherited |
indicates whether the translation is lossless (e.g., ranges) or not
Definition at line 382 of file DBTranslator.h.
|
protectedinherited |
the maximum number of entries that the dictionary is allowed to contain
Definition at line 388 of file DBTranslator.h.
|
protectedinherited |
the set of missing symbols
Definition at line 391 of file DBTranslator.h.
|
protectedinherited |
the type of the values translated by the translator
Definition at line 402 of file DBTranslator.h.