![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
The databases' cell translators for continuous variables. More...
#include <agrum/tools/database/DBTranslator4ContinuousVariable.h>
Public Member Functions | |
Constructors / Destructors | |
template<template< typename > class XALLOC> | |
DBTranslator4ContinuousVariable (const std::vector< std::string, XALLOC< std::string > > &missing_symbols, const bool fit_range=false, const allocator_type &alloc=allocator_type()) | |
default constructor without any initial variable More... | |
DBTranslator4ContinuousVariable (const bool fit_range=false, const allocator_type &alloc=allocator_type()) | |
default constructor without any initial variable nor missing symbol More... | |
template<typename GUM_SCALAR , template< typename > class XALLOC> | |
DBTranslator4ContinuousVariable (const ContinuousVariable< GUM_SCALAR > &var, const std::vector< std::string, XALLOC< std::string > > &missing_symbols, const bool fit_range=false, const allocator_type &alloc=allocator_type()) | |
default constructor with a continuous variable as translator More... | |
template<typename GUM_SCALAR > | |
DBTranslator4ContinuousVariable (const ContinuousVariable< GUM_SCALAR > &var, const bool fit_range=false, const allocator_type &alloc=allocator_type()) | |
default constructor with a continuous variable as translator but without missing symbol More... | |
template<template< typename > class XALLOC> | |
DBTranslator4ContinuousVariable (const IContinuousVariable &var, const std::vector< std::string, XALLOC< std::string > > &missing_symbols, const bool fit_range=false, const allocator_type &alloc=allocator_type()) | |
default constructor with a IContinuous variable as translator More... | |
DBTranslator4ContinuousVariable (const IContinuousVariable &var, const bool fit_range=false, const allocator_type &alloc=allocator_type()) | |
default constructor with a IContinuous variable as translator but without missing symbol More... | |
DBTranslator4ContinuousVariable (const DBTranslator4ContinuousVariable< ALLOC > &from) | |
copy constructor More... | |
DBTranslator4ContinuousVariable (const DBTranslator4ContinuousVariable< ALLOC > &from, const allocator_type &alloc) | |
copy constructor with a given allocator More... | |
DBTranslator4ContinuousVariable (DBTranslator4ContinuousVariable< ALLOC > &&from) | |
move constructor More... | |
DBTranslator4ContinuousVariable (DBTranslator4ContinuousVariable< ALLOC > &&from, const allocator_type &alloc) | |
move constructor with a given allocator More... | |
virtual DBTranslator4ContinuousVariable< ALLOC > * | clone () const |
virtual copy constructor More... | |
virtual DBTranslator4ContinuousVariable< ALLOC > * | clone (const allocator_type &alloc) const |
virtual copy constructor with a given allocator More... | |
virtual | ~DBTranslator4ContinuousVariable () |
destructor More... | |
Operators | |
DBTranslator4ContinuousVariable< ALLOC > & | operator= (const DBTranslator4ContinuousVariable< ALLOC > &from) |
copy operator More... | |
DBTranslator4ContinuousVariable< ALLOC > & | operator= (DBTranslator4ContinuousVariable< ALLOC > &&from) |
move operator More... | |
Accessors / Modifiers | |
virtual DBTranslatedValue | translate (const std::string &str) final |
returns the translation of a string More... | |
virtual std::string | translateBack (const DBTranslatedValue translated_val) const final |
returns the original value for a given translation More... | |
virtual std::size_t | domainSize () const final |
returns std::numeric_limits<std::size_t>::max () More... | |
virtual bool | needsReordering () const final |
indicates that the translations should never be reordered More... | |
virtual HashTable< std::size_t, std::size_t, ALLOC< std::pair< std::size_t, std::size_t > > > | reorder () final |
returns an empty mapping, indicating that old tanslations are equal to the newly reordered ones. More... | |
virtual const IContinuousVariable * | variable () const final |
returns the variable stored into the translator More... | |
virtual DBTranslatedValue | missingValue () const final |
returns the translation of a missing value More... | |
Operators | |
DBTranslatedValue | operator<< (const std::string &str) |
alias for method translate More... | |
std::string | operator>> (const DBTranslatedValue translated_val) |
alias for method translateBack More... | |
Accessors / Modifiers | |
virtual bool | hasEditableDictionary () const |
indicates whether the translator has an editable dictionary or not More... | |
virtual void | setEditableDictionaryMode (bool new_mode) |
sets/unset the editable dictionary mode More... | |
const Set< std::string, ALLOC< std::string > > & | missingSymbols () const |
returns the set of missing symbols taken into account by the translator More... | |
bool | isMissingSymbol (const std::string &str) const |
indicates whether a string corresponds to a missing symbol More... | |
void | setVariableName (const std::string &str) const |
sets the name of the variable stored into the translator More... | |
void | setVariableDescription (const std::string &str) const |
sets the name of the variable stored into the translator More... | |
DBTranslatedValueType | getValType () const |
returns the type of values handled by the translator More... | |
allocator_type | getAllocator () const |
returns the allocator used by the translator More... | |
bool | isMissingValue (const DBTranslatedValue &val) const |
indicates whether a translated value corresponds to a missing value More... | |
Public Types | |
using | allocator_type = typename DBTranslator< ALLOC >::allocator_type |
type for the allocators passed in arguments of methods More... | |
Protected Attributes | |
bool | is_dictionary_dynamic_ |
indicates whether the dictionary can be updated or not More... | |
std::size_t | max_dico_entries_ |
the maximum number of entries that the dictionary is allowed to contain More... | |
Set< std::string, ALLOC< std::string > > | missing_symbols_ |
the set of missing symbols More... | |
Bijection< std::size_t, std::string, ALLOC< std::pair< float, std::string > > > | back_dico_ |
the bijection relating back translated values and their original strings. More... | |
DBTranslatedValueType | val_type_ |
the type of the values translated by the translator More... | |
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 126 of file DBTranslator4ContinuousVariable.h.
using gum::learning::DBTranslator4ContinuousVariable< ALLOC >::allocator_type = typename DBTranslator< ALLOC >::allocator_type |
type for the allocators passed in arguments of methods
Definition at line 129 of file DBTranslator4ContinuousVariable.h.
gum::learning::DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable | ( | const std::vector< std::string, XALLOC< std::string > > & | missing_symbols, |
const bool | fit_range = false , |
||
const allocator_type & | alloc = allocator_type() |
||
) |
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) |
alloc | The allocator used to allocate memory for all the fields of the DBTranslator4ContinuousVariable |
gum::learning::DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable | ( | const bool | fit_range = false , |
const allocator_type & | alloc = allocator_type() |
||
) |
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) |
alloc | The allocator used to allocate memory for all the fields of the DBTranslator4ContinuousVariable |
gum::learning::DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable | ( | const ContinuousVariable< GUM_SCALAR > & | var, |
const std::vector< std::string, XALLOC< std::string > > & | missing_symbols, | ||
const bool | fit_range = false , |
||
const allocator_type & | alloc = allocator_type() |
||
) |
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) |
alloc | The allocator used to allocate memory for all the fields of the DBTranslator4ContinuousVariable |
gum::learning::DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable | ( | const ContinuousVariable< GUM_SCALAR > & | var, |
const bool | fit_range = false , |
||
const allocator_type & | alloc = allocator_type() |
||
) |
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) |
alloc | The allocator used to allocate memory for all the fields of the DBTranslator4ContinuousVariable |
gum::learning::DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable | ( | const IContinuousVariable & | var, |
const std::vector< std::string, XALLOC< std::string > > & | missing_symbols, | ||
const bool | fit_range = false , |
||
const allocator_type & | alloc = allocator_type() |
||
) |
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) |
alloc | The allocator used to allocate memory for all the fields of the DBTranslator4ContinuousVariable |
gum::learning::DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable | ( | const IContinuousVariable & | var, |
const bool | fit_range = false , |
||
const allocator_type & | alloc = allocator_type() |
||
) |
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) |
alloc | The allocator used to allocate memory for all the fields of the DBTranslator4ContinuousVariable |
gum::learning::DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable | ( | const DBTranslator4ContinuousVariable< ALLOC > & | from | ) |
copy constructor
gum::learning::DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable | ( | const DBTranslator4ContinuousVariable< ALLOC > & | from, |
const allocator_type & | alloc | ||
) |
copy constructor with a given allocator
gum::learning::DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable | ( | DBTranslator4ContinuousVariable< ALLOC > && | from | ) |
move constructor
gum::learning::DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable | ( | DBTranslator4ContinuousVariable< ALLOC > && | from, |
const allocator_type & | alloc | ||
) |
move constructor with a given allocator
|
virtual |
destructor
|
virtual |
virtual copy constructor
Implements gum::learning::DBTranslator< ALLOC >.
|
virtual |
virtual copy constructor with a given allocator
Implements gum::learning::DBTranslator< ALLOC >.
|
finalvirtual |
returns std::numeric_limits<std::size_t>::max ()
Implements gum::learning::DBTranslator< ALLOC >.
|
inherited |
returns the allocator used by the translator
|
inherited |
returns the type of values handled by the translator
|
virtualinherited |
indicates whether the translator has an editable dictionary or not
Reimplemented in gum::learning::DBTranslator4DiscretizedVariable< ALLOC >.
|
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< ALLOC >.
|
finalvirtual |
indicates that the translations should never be reordered
Implements gum::learning::DBTranslator< ALLOC >.
|
inherited |
alias for method translate
DBTranslator4ContinuousVariable< ALLOC >& gum::learning::DBTranslator4ContinuousVariable< ALLOC >::operator= | ( | const DBTranslator4ContinuousVariable< ALLOC > & | from | ) |
copy operator
DBTranslator4ContinuousVariable< ALLOC >& gum::learning::DBTranslator4ContinuousVariable< ALLOC >::operator= | ( | DBTranslator4ContinuousVariable< ALLOC > && | from | ) |
move operator
|
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< ALLOC >.
|
virtualinherited |
sets/unset the editable dictionary mode
Reimplemented in gum::learning::DBTranslator4DiscretizedVariable< ALLOC >.
|
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< ALLOC >.
|
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< ALLOC >.
|
finalvirtual |
returns the variable stored into the translator
Implements gum::learning::DBTranslator< ALLOC >.
|
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 388 of file DBTranslator.h.
|
protectedinherited |
indicates whether the dictionary can be updated or not
Definition at line 373 of file DBTranslator.h.
|
protectedinherited |
the maximum number of entries that the dictionary is allowed to contain
Definition at line 376 of file DBTranslator.h.
|
protectedinherited |
the set of missing symbols
Definition at line 379 of file DBTranslator.h.
|
protectedinherited |
the type of the values translated by the translator
Definition at line 391 of file DBTranslator.h.