![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
the class used to read a row in the database and to transform it into a set of DBRow instances that can be used for learning. More...
#include <agrum/base/database/DBRowGeneratorParser.h>
Public Member Functions | |
Constructors / Destructors | |
| DBRowGeneratorParser (const typename DatabaseTable::Handler &handler, const DBRowGeneratorSet &generator_set) | |
| default constructor | |
| DBRowGeneratorParser (const DBRowGeneratorParser &from) | |
| copy constructor | |
| DBRowGeneratorParser (DBRowGeneratorParser &&filter) | |
| move constructor | |
| virtual DBRowGeneratorParser * | clone () const |
| virtual copy constructor | |
| virtual | ~DBRowGeneratorParser () |
| destructor | |
Operators | |
| DBRowGeneratorParser & | operator= (const DBRowGeneratorParser &from) |
| copy operator | |
| DBRowGeneratorParser & | operator= (DBRowGeneratorParser &&from) |
| move operator | |
Accessors / Modifiers | |
| bool | hasRows () |
| returns true if there are still rows that can be output by the DBRowGeneratorParser | |
| const DBRow< DBTranslatedValue > & | row () |
| returns a new output row with its corresponding weight | |
| void | reset () |
| resets the parser | |
| DatabaseTable::Handler & | handler () |
| returns the handler used by the parser | |
| const DatabaseTable::Handler & | handler () const |
| returns the handler used by the parser | |
| const DatabaseTable & | database () const |
| returns a reference on the database | |
| DBRowGeneratorSet & | generatorSet () |
| returns the generator set that is actually used | |
| const DBRowGeneratorSet & | generatorSet () const |
| returns the generator set that is actually used | |
| void | setRange (std::size_t begin, std::size_t end) |
| sets the area in the database the handler will handle | |
| void | setColumnsOfInterest (const std::vector< std::size_t > &cols_of_interest) |
| sets the columns of interest: the output DBRow needs only contain values fot these columns | |
| void | setColumnsOfInterest (std::vector< std::size_t > &&cols_of_interest) |
| sets the columns of interest: the output DBRow needs only contain values fot these columns | |
| template<typename GUM_SCALAR> | |
| void | setBayesNet (const BayesNet< GUM_SCALAR > &new_bn) |
| assign a new Bayes net to all the generators that depend on a BN | |
Private Attributes | |
| DatabaseTable::Handler | _handler_ |
| the handler that is really used to parse the database | |
| DBRowGeneratorSet | _generator_set_ |
| the set of DBRow generators (might be empty) | |
| std::size_t | _generator_size_ |
| the size of the generator set | |
the class used to read a row in the database and to transform it into a set of DBRow instances that can be used for learning.
A DBRowGeneratorParser contains a handler on a DatabaseTable that enables it to parse DBRows contained in the DatabaseTable. It also contains a DBRowGeneratorSet that is used to create output rows for each parsed DBRow. Note that if the DBRowGeneratorSet is empty, then DBRowGeneratorParser simply outputs each parsed DBRow without additional processing. To understand the difference between a DBRowGeneratorParser and a DBRowGeneratorSet, the latter is designed to take as input only one DBRow instance and to produce some output DBRow instances, whereas the former is designed to parse the content of a DatabaseTable and to produce from them some output DBRow instances.
Definition at line 84 of file DBRowGeneratorParser.h.
| gum::learning::DBRowGeneratorParser::DBRowGeneratorParser | ( | const typename DatabaseTable::Handler & | handler, |
| const DBRowGeneratorSet & | generator_set ) |
default constructor
References handler().
Referenced by DBRowGeneratorParser(), DBRowGeneratorParser(), clone(), operator=(), and operator=().
| gum::learning::DBRowGeneratorParser::DBRowGeneratorParser | ( | const DBRowGeneratorParser & | from | ) |
| gum::learning::DBRowGeneratorParser::DBRowGeneratorParser | ( | DBRowGeneratorParser && | filter | ) |
|
virtual |
destructor
|
virtual |
virtual copy constructor
References DBRowGeneratorParser().
| const DatabaseTable & gum::learning::DBRowGeneratorParser::database | ( | ) | const |
returns a reference on the database
| DBRowGeneratorSet & gum::learning::DBRowGeneratorParser::generatorSet | ( | ) |
returns the generator set that is actually used
| const DBRowGeneratorSet & gum::learning::DBRowGeneratorParser::generatorSet | ( | ) | const |
returns the generator set that is actually used
| DatabaseTable::Handler & gum::learning::DBRowGeneratorParser::handler | ( | ) |
returns the handler used by the parser
Referenced by DBRowGeneratorParser().
| const DatabaseTable::Handler & gum::learning::DBRowGeneratorParser::handler | ( | ) | const |
returns the handler used by the parser
| bool gum::learning::DBRowGeneratorParser::hasRows | ( | ) |
returns true if there are still rows that can be output by the DBRowGeneratorParser
The usual way of calling this method is to encapsulate it into a while loop whose stopping condition is when the handler has no more rows. This loop shall be inside a try-catch statement that enables to stop properly the loop when the NotFound exception is raised. In most practical cases, this exception will never be raised, but if you use a row generator that enables to return 0 row (say, for instance an intelligent EM that does not return any row when there are too many missing data) and if the last rows of the database are such that this generator will return no row, then the exception will be raised. Actually, it is not efficient to parse all the database to detect such a case before trying to return the rows, especially because this situation is very unlikely to occur. So a correct code to use method row () is like:
| DBRowGeneratorParser & gum::learning::DBRowGeneratorParser::operator= | ( | const DBRowGeneratorParser & | from | ) |
| DBRowGeneratorParser & gum::learning::DBRowGeneratorParser::operator= | ( | DBRowGeneratorParser && | from | ) |
| void gum::learning::DBRowGeneratorParser::reset | ( | ) |
resets the parser
| const DBRow< DBTranslatedValue > & gum::learning::DBRowGeneratorParser::row | ( | ) |
returns a new output row with its corresponding weight
The usual way of calling this method is to encapsulate it into a while loop whose stopping condition is when the handler has no more rows. This loop shall be inside a try-catch statement that enables to stop properly the loop when the NotFound exception is raised. In most practical cases, this exception will never be raised, but if you use a row generator that enables to return 0 row (say, for instance an intelligent EM that does not return any row when there are too many missing data) and if the last rows of the database are such that this generator will return no row, then the exception will be raised. Actually, it is not efficient to parse all the database to detect such a case before trying to return the rows, especially because this situation is very unlikely to occur. So a correct code to use method row () is like:
| void gum::learning::DBRowGeneratorParser::setBayesNet | ( | const BayesNet< GUM_SCALAR > & | new_bn | ) |
assign a new Bayes net to all the generators that depend on a BN
Typically, generators based on EM or K-means depend on a model to compute correctly their outputs. Method setBayesNet enables to update their BN model.
| void gum::learning::DBRowGeneratorParser::setColumnsOfInterest | ( | const std::vector< std::size_t > & | cols_of_interest | ) |
sets the columns of interest: the output DBRow needs only contain values fot these columns
This method is useful, e.g., for EM-like algorithms that need to know which unobserved variables/values need be filled.
| OperationNotAllowed | is raised if the generator set has already started generating output rows and is currently in a state where the generation is not completed yet (i.e., we still need to call the generate() method to complete it). |
| void gum::learning::DBRowGeneratorParser::setColumnsOfInterest | ( | std::vector< std::size_t > && | cols_of_interest | ) |
sets the columns of interest: the output DBRow needs only contain values fot these columns
This method is useful, e.g., for EM-like algorithms that need to know which unobserved variables/values need be filled.
| OperationNotAllowed | is raised if the generator set has already started generating output rows and is currently in a state where the generation is not completed yet (i.e., we still need to call the generate() method to complete it). |
| void gum::learning::DBRowGeneratorParser::setRange | ( | std::size_t | begin, |
| std::size_t | end ) |
sets the area in the database the handler will handle
In addition to setting the area that will be parsed by the handler, this method makes the handler point to the beginning of the area.
| begin | the first row to be handled |
| end | the handler handles rows in interval [begin,end). Thus, the endth row is not included in the set of rows handled. |
| NullElement | is raised if the handler does not point to any database |
| SizeError | is raised if end is greater than the number of rows of the database |
|
private |
the set of DBRow generators (might be empty)
Definition at line 256 of file DBRowGeneratorParser.h.
|
private |
the size of the generator set
Definition at line 259 of file DBRowGeneratorParser.h.
|
private |
the handler that is really used to parse the database
Definition at line 253 of file DBRowGeneratorParser.h.