![]() |
aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
|
The class representing the original values of the cells of databases. More...
#include <agrum/base/database/DBCell.h>
Public Types | |
| enum class | EltType : unsigned char { REAL , INTEGER , STRING , MISSING } |
| the set of types possibly taken by the last element read More... | |
Public Member Functions | |
Constructors / Destructors | |
| DBCell () | |
| default constructor (ontains a missing value) | |
| DBCell (const float nb) | |
| constructor for a real number | |
| DBCell (const int nb) | |
| constructor for an integer number | |
| DBCell (const std::string &str) | |
| constructor for a string | |
| DBCell (const DBCell &from) | |
| copy constructor | |
| DBCell (DBCell &&from) | |
| move constructor | |
| ~DBCell () | |
| destructor | |
Operators | |
| DBCell & | operator= (const DBCell &from) |
| copy operator | |
| DBCell & | operator= (DBCell &&from) |
| move operator | |
| DBCell & | operator= (const float x) |
| assignment operator | |
| DBCell & | operator= (const int x) |
| assignment operator | |
| DBCell & | operator= (const std::string &x) |
| assignment operator | |
| bool | operator== (const DBCell &from) const |
| test of equality | |
Accessors / Modifiers | |
| EltType | type () const noexcept |
| returns the current type of the DBCell | |
| bool | convertType (const EltType newtype) |
| try to convert the content of the DBCell into another type | |
| float | real () const |
| returns the DBcell as a real number | |
| void | setReal (const float x) |
| sets the content of the DBCell | |
| void | setReal (std::string_view elt) |
| sets the content of the DBCell from a string | |
| int | integer () const |
| returns the DBcell as an integer | |
| void | setInteger (const int x) |
| sets the content of the DBCell | |
| void | setInteger (std::string_view elt) |
| sets the content of the DBCell from a string | |
| const std::string & | string () const |
| returns the DBcell as a string | |
| int | stringIndex () const |
| returns the DBcell as the index of a string in a static bijection | |
| void | setString (const std::string &elt) |
| sets the content of the DBCell | |
| void | setMissingState () |
| sets the DBCell as a missing element | |
| bool | isMissing () const |
| indicates whether the cell contains a missing value | |
Public Static Accessors / Modifiers | |
| std::string | toString (const std::vector< std::string > &missingVals) const |
| returns the content of the DBCell as a string, whatever its type | |
| static const std::string & | string (const int index) |
| strings are stored into a static bijection. Get its ith string | |
| static EltType | bestType (std::string_view str, const std::vector< std::string > &missingVals) |
| returns the best type to store a given element encoded as a string | |
| static DBCell | bestDBCell (std::string_view str, const std::vector< std::string > &missingVals) |
| returns the DBCell with the best type for an element encoded as a string | |
| static bool | isInteger (std::string_view str) |
| determines whether a string corresponds precisely to an integer | |
| static bool | isReal (std::string_view str) |
| determine whether a string corresponds precisely to a real number | |
| static bool | isMissing (std::string_view str, const std::vector< std::string > &missingVals) |
| checks whether a string correspond to a missing value | |
The class representing the original values of the cells of databases.
Learning algorithms read input data, the so-called datasets, and infer their models. To be fast, they should not parse directly the original datasets, which are often databases of strings, but rather they should parse preprocessed data with types more suited for fast analysis. To do so, in aGrUM, learning algorithms parse datasets of DBTranslatedValue instances. However, sometimes, these algorithms make some decisions which, afterwards, they may realize were not so good and should be modified. For instance, when coping with continuous variables, they may use a discretization for fast learning the structure of a hybrid Bayesian network. But, given the structure found, they may try to find a better discretization. With a new discretization, the original dataset should be parsed again and mapped into new DBTranslatedValue instances. Unfortunately, reparsing, say, a CSV file or a SQL database, is time consuming. Sometimes, it is faster to read such datasets once and store them in an appropriate form that can be mapped easily into DBTranslatedValue instances. The RawDatabaseTable class is made precisely for this purpose and can be thought of as a 2-dimensional table, the elements of which are DBCell instances. The latter can actually encode compactly integers, real numbers, strings and even missing values. So they are very well suited to be the type of the cells of the RawDatabaseTable class.
|
strong |
| gum::learning::DBCell::DBCell | ( | ) |
default constructor (ontains a missing value)
Referenced by DBCell(), DBCell(), bestDBCell(), operator=(), operator=(), operator=(), operator=(), operator=(), and operator==().
| gum::learning::DBCell::DBCell | ( | const float | nb | ) |
constructor for a real number
| gum::learning::DBCell::DBCell | ( | const int | nb | ) |
constructor for an integer number
| gum::learning::DBCell::DBCell | ( | const std::string & | str | ) |
constructor for a string
| gum::learning::DBCell::DBCell | ( | const DBCell & | from | ) |
| gum::learning::DBCell::DBCell | ( | DBCell && | from | ) |
| gum::learning::DBCell::~DBCell | ( | ) |
destructor
|
static |
returns the DBCell with the best type for an element encoded as a string
| str | the string to convert into a DBCell |
| missingVals | a vector containing the set of strings that should be interpreted as missing values. Whenever str matches one these strings, the returned DBCell represents a missing value. |
References DBCell(), and bestDBCell().
Referenced by bestDBCell().
|
static |
returns the best type to store a given element encoded as a string
| str | the string to convert into a DBCell |
| missingVals | a vector containing the set of strings that should be interpreted as missing values. Whenever str matches one these strings, the returned EltType represents a missing value. |
References bestType().
Referenced by bestType().
try to convert the content of the DBCell into another type
References convertType().
Referenced by convertType().
| int gum::learning::DBCell::integer | ( | ) | const |
returns the DBcell as an integer
References integer().
Referenced by integer().
|
static |
determines whether a string corresponds precisely to an integer
References isInteger().
Referenced by isInteger().
| bool gum::learning::DBCell::isMissing | ( | ) | const |
indicates whether the cell contains a missing value
References isMissing().
Referenced by isMissing(), and isMissing().
|
static |
checks whether a string correspond to a missing value
References isMissing(), and MISSING.
|
static |
| DBCell & gum::learning::DBCell::operator= | ( | const float | x | ) |
| DBCell & gum::learning::DBCell::operator= | ( | const int | x | ) |
| DBCell & gum::learning::DBCell::operator= | ( | const std::string & | x | ) |
| float gum::learning::DBCell::real | ( | ) | const |
returns the DBcell as a real number
References real().
Referenced by real().
| void gum::learning::DBCell::setInteger | ( | const int | x | ) |
sets the content of the DBCell
References setInteger().
Referenced by setInteger(), and setInteger().
| void gum::learning::DBCell::setInteger | ( | std::string_view | elt | ) |
sets the content of the DBCell from a string
| TypeError | if the string does not correspond to an integer |
References setInteger().
| void gum::learning::DBCell::setMissingState | ( | ) |
sets the DBCell as a missing element
References setMissingState().
Referenced by setMissingState().
| void gum::learning::DBCell::setReal | ( | const float | x | ) |
| void gum::learning::DBCell::setReal | ( | std::string_view | elt | ) |
| void gum::learning::DBCell::setString | ( | const std::string & | elt | ) |
sets the content of the DBCell
References setString().
Referenced by setString().
| const std::string & gum::learning::DBCell::string | ( | ) | const |
|
static |
strings are stored into a static bijection. Get its ith string
| UndefinedElement | if the index does not correspond to any string |
| int gum::learning::DBCell::stringIndex | ( | ) | const |
returns the DBcell as the index of a string in a static bijection
All strings referenced by DBCells are stored in a bijection. This method returns the index of the string referenced by the current DBCell.
References stringIndex().
Referenced by stringIndex().
| std::string gum::learning::DBCell::toString | ( | const std::vector< std::string > & | missingVals | ) | const |
returns the content of the DBCell as a string, whatever its type
| UndefinedElement | is raised if the DBCell corresponds to a missing value but the set of missing values passed in argument is empty. |
References toString().
Referenced by toString().