aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::learning::DBRowGeneratorWithBN< GUM_SCALAR > Class Template Referenceabstract

Base class for DBRowGenerator classes that use a BN for computing their outputs. More...

#include <agrum/base/database/DBRowGeneratorWithBN.h>

Inheritance diagram for gum::learning::DBRowGeneratorWithBN< GUM_SCALAR >:
Collaboration diagram for gum::learning::DBRowGeneratorWithBN< GUM_SCALAR >:

Public Member Functions

Constructors / Destructors
 DBRowGeneratorWithBN (const std::vector< DBTranslatedValueType > &column_types, const BayesNet< GUM_SCALAR > &bn, const DBRowGeneratorGoal goal, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
 default constructor
 DBRowGeneratorWithBN (const DBRowGeneratorWithBN< GUM_SCALAR > &from)
 copy constructor
 DBRowGeneratorWithBN (DBRowGeneratorWithBN< GUM_SCALAR > &&from)
 move constructor
 ~DBRowGeneratorWithBN ()
 destructor
Accessors / Modifiers
virtual void setBayesNet (const BayesNet< GUM_SCALAR > &new_bn)
 assign a new Bayes net to the generator
const BayesNet< GUM_SCALAR > & getBayesNet () const
 returns the Bayes net used by the generator
Constructors / Destructors
virtual DBRowGeneratorclone () const =0
 virtual copy constructor
Accessors / Modifiers
bool hasRows ()
 returns true if there are still rows that can be output by the DBRowGenerator
bool setInputRow (const DBRow< DBTranslatedValue > &row)
 sets the input row from which the generator will create its output rows
virtual const DBRow< DBTranslatedValue > & generate ()=0
 generate new rows from the input row
void decreaseRemainingRows ()
 decrease the number of remaining output rows
virtual void reset ()
 resets the generator. There are therefore no more ouput row to generate
virtual void setColumnsOfInterest (const std::vector< std::size_t > &cols_of_interest)
 sets the columns of interest: the output DBRow needs only contain correct values fot these columns
virtual void setColumnsOfInterest (std::vector< std::size_t > &&cols_of_interest)
 sets the columns of interest: the output DBRow needs only contain correct values fot these columns
const std::vector< std::size_t > & columnsOfInterest () const
 returns the current set of columns of interest
DBRowGeneratorGoal goal () const
 returns the goal of the DBRowGenerator

Protected Member Functions

DBRowGeneratorWithBN< GUM_SCALAR > & operator= (const DBRowGeneratorWithBN< GUM_SCALAR > &from)
 copy operator
DBRowGeneratorWithBN< GUM_SCALAR > & operator= (DBRowGeneratorWithBN< GUM_SCALAR > &&from)
 move operator
virtual std::size_t computeRows_ (const DBRow< DBTranslatedValue > &row)=0
 the method that computes the set of DBRow instances to output after method setInputRow has been called

Protected Attributes

const BayesNet< GUM_SCALAR > * bn_
 the Bayesian network used to fill the unobserved values
Bijection< NodeId, std::size_t > nodeId2columns_
 the mapping betwen the BN's node ids and the database's columns
std::size_t nb_remaining_output_rows_ {std::size_t(0)}
 the number of output rows still to retrieve through the generate method
std::vector< DBTranslatedValueTypecolumn_types_
 the types of the columns in the DatabaseTable
std::vector< std::size_t > columns_of_interest_
 the set of columns of interest
DBRowGeneratorGoal goal_ {DBRowGeneratorGoal::OTHER_THINGS_THAN_REMOVE_MISSING_VALUES}
 the goal of the DBRowGenerator (just remove missing values or not)

Detailed Description

template<typename GUM_SCALAR = double>
class gum::learning::DBRowGeneratorWithBN< GUM_SCALAR >

Base class for DBRowGenerator classes that use a BN for computing their outputs.

This class is a DBRowGenerator that fills the unobserved values of the nodes of interest as the WithBN algorithm does, i.e., by returning all the possible completed rows with a weight corresponding to the probability of the completion. The standard usage of a DBRowGenerator is the following:

// create a DatabaseTable and fill it
for ( int i = 0; i < 10; ++i )
// fill the database
// keep in a vector the types of the columns in the database
const std::vector<gum::learning::DBTranslatedValueType>
// create the generator
gum::learning::DBRowGeneratorWithBN generator ( col_types );
// parse the database and produce output rows
for ( auto dbrow : database ) {
generator.setInputRow ( dbrow );
while ( generator.hasRows() ) {
const auto& output_dbrow = generator.generate ();
// do something with the output dbrow
}
}
Base class for DBRowGenerator classes that use a BN for computing their outputs.
The databases' cell translators for labelized variables.
the class for packing together the translators used to preprocess the datasets
std::size_t insertTranslator(const DBTranslator &translator, const std::size_t column, const bool unique_column=true)
inserts a new translator at the end of the translator set
The class representing a tabular database as used by learning tasks.

Definition at line 100 of file DBRowGeneratorWithBN.h.

Constructor & Destructor Documentation

◆ DBRowGeneratorWithBN() [1/3]

template<typename GUM_SCALAR = double>
gum::learning::DBRowGeneratorWithBN< GUM_SCALAR >::DBRowGeneratorWithBN ( const std::vector< DBTranslatedValueType > & column_types,
const BayesNet< GUM_SCALAR > & bn,
const DBRowGeneratorGoal goal,
const Bijection< NodeId, std::size_t > & nodeId2columns = BijectionNodeId, std::size_t >() )

default constructor

References gum::learning::DBRowGenerator::goal().

Referenced by DBRowGeneratorWithBN(), DBRowGeneratorWithBN(), operator=(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DBRowGeneratorWithBN() [2/3]

template<typename GUM_SCALAR = double>
gum::learning::DBRowGeneratorWithBN< GUM_SCALAR >::DBRowGeneratorWithBN ( const DBRowGeneratorWithBN< GUM_SCALAR > & from)

copy constructor

References DBRowGeneratorWithBN().

Here is the call graph for this function:

◆ DBRowGeneratorWithBN() [3/3]

template<typename GUM_SCALAR = double>
gum::learning::DBRowGeneratorWithBN< GUM_SCALAR >::DBRowGeneratorWithBN ( DBRowGeneratorWithBN< GUM_SCALAR > && from)

move constructor

References DBRowGeneratorWithBN().

Here is the call graph for this function:

◆ ~DBRowGeneratorWithBN()

template<typename GUM_SCALAR = double>
gum::learning::DBRowGeneratorWithBN< GUM_SCALAR >::~DBRowGeneratorWithBN ( )

destructor

Member Function Documentation

◆ clone()

virtual DBRowGenerator * gum::learning::DBRowGenerator::clone ( ) const
pure virtualinherited

virtual copy constructor

Implemented in gum::learning::DBRowGenerator4CompleteRows, gum::learning::DBRowGeneratorEM< GUM_SCALAR >, and gum::learning::DBRowGeneratorIdentity.

References DBRowGenerator().

Here is the call graph for this function:

◆ columnsOfInterest()

const std::vector< std::size_t > & gum::learning::DBRowGenerator::columnsOfInterest ( ) const
inherited

returns the current set of columns of interest

◆ computeRows_()

virtual std::size_t gum::learning::DBRowGenerator::computeRows_ ( const DBRow< DBTranslatedValue > & row)
protectedpure virtualinherited

the method that computes the set of DBRow instances to output after method setInputRow has been called

Implemented in gum::learning::DBRowGenerator4CompleteRows, gum::learning::DBRowGeneratorEM< GUM_SCALAR >, and gum::learning::DBRowGeneratorIdentity.

◆ decreaseRemainingRows()

void gum::learning::DBRowGenerator::decreaseRemainingRows ( )
inherited

decrease the number of remaining output rows

When method setInputRow is performed, the DBRowGenerator knows how many output rows it will be able to generate. Each time method decreaseRemainingRows is called, we decrement this number. When the number becomes equal to 0, then there remains no new output row to generate.

◆ generate()

virtual const DBRow< DBTranslatedValue > & gum::learning::DBRowGenerator::generate ( )
pure virtualinherited

◆ getBayesNet()

template<typename GUM_SCALAR = double>
const BayesNet< GUM_SCALAR > & gum::learning::DBRowGeneratorWithBN< GUM_SCALAR >::getBayesNet ( ) const

returns the Bayes net used by the generator

◆ goal()

DBRowGeneratorGoal gum::learning::DBRowGenerator::goal ( ) const
inherited

returns the goal of the DBRowGenerator

Referenced by DBRowGenerator(), and gum::learning::DBRowGeneratorWithBN< GUM_SCALAR >::DBRowGeneratorWithBN().

Here is the caller graph for this function:

◆ hasRows()

bool gum::learning::DBRowGenerator::hasRows ( )
inherited

returns true if there are still rows that can be output by the DBRowGenerator

◆ operator=() [1/2]

template<typename GUM_SCALAR = double>
DBRowGeneratorWithBN< GUM_SCALAR > & gum::learning::DBRowGeneratorWithBN< GUM_SCALAR >::operator= ( const DBRowGeneratorWithBN< GUM_SCALAR > & from)
protected

copy operator

References DBRowGeneratorWithBN().

Here is the call graph for this function:

◆ operator=() [2/2]

template<typename GUM_SCALAR = double>
DBRowGeneratorWithBN< GUM_SCALAR > & gum::learning::DBRowGeneratorWithBN< GUM_SCALAR >::operator= ( DBRowGeneratorWithBN< GUM_SCALAR > && from)
protected

move operator

References DBRowGeneratorWithBN().

Here is the call graph for this function:

◆ reset()

virtual void gum::learning::DBRowGenerator::reset ( )
virtualinherited

resets the generator. There are therefore no more ouput row to generate

◆ setBayesNet()

template<typename GUM_SCALAR = double>
virtual void gum::learning::DBRowGeneratorWithBN< GUM_SCALAR >::setBayesNet ( const BayesNet< GUM_SCALAR > & new_bn)
virtual

assign a new Bayes net to the generator

◆ setColumnsOfInterest() [1/2]

virtual void gum::learning::DBRowGenerator::setColumnsOfInterest ( const std::vector< std::size_t > & cols_of_interest)
virtualinherited

sets the columns of interest: the output DBRow needs only contain correct 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. In this case, the DBRowGenerator still outputs DBRows with the same columns as the DatabaseTable, but only the columns of these DBRows corresponding to those passed in argument to Method setColumnsOfInterest are meaningful. For instance, if a DatabaseTable contains 10 columns and Method setColumnsOfInterest() is applied with vector<> { 0, 3, 4 }, then the DBRowGenerator will output DBRows with 10 columns, in which only columns 0, 3 and 4 are guaranteed to have correct values (columns are always indexed, starting from 0).

◆ setColumnsOfInterest() [2/2]

virtual void gum::learning::DBRowGenerator::setColumnsOfInterest ( std::vector< std::size_t > && cols_of_interest)
virtualinherited

sets the columns of interest: the output DBRow needs only contain correct 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. In this case, the DBRowGenerator still outputs DBRows with the same columns as the DatabaseTable, but only the columns of these DBRows corresponding to those passed in argument to Method setColumnsOfInterest are meaningful. For instance, if a DatabaseTable contains 10 columns and Method setColumnsOfInterest() is applied with vector<> { 0, 3, 4 }, then the DBRowGenerator will output DBRows with 10 columns, in which only columns 0, 3 and 4 are guaranteed to have correct values (columns are always indexed, starting from 0).

◆ setInputRow()

bool gum::learning::DBRowGenerator::setInputRow ( const DBRow< DBTranslatedValue > & row)
inherited

sets the input row from which the generator will create its output rows

Returns
a Boolean indicating whether, from this input DBRow, the DBRowGenerator is capable of outputing at least one row or not

Member Data Documentation

◆ bn_

template<typename GUM_SCALAR = double>
const BayesNet< GUM_SCALAR >* gum::learning::DBRowGeneratorWithBN< GUM_SCALAR >::bn_
protected

the Bayesian network used to fill the unobserved values

Definition at line 144 of file DBRowGeneratorWithBN.h.

◆ column_types_

std::vector< DBTranslatedValueType > gum::learning::DBRowGenerator::column_types_
protectedinherited

the types of the columns in the DatabaseTable

This is useful to determine whether we need to use the .discr_val field or the .cont_val field in DBTranslatedValue instances.

Definition at line 330 of file DBRowGenerator.h.

◆ columns_of_interest_

std::vector< std::size_t > gum::learning::DBRowGenerator::columns_of_interest_
protectedinherited

the set of columns of interest

Definition at line 333 of file DBRowGenerator.h.

◆ goal_

DBRowGeneratorGoal gum::learning::DBRowGenerator::goal_ {DBRowGeneratorGoal::OTHER_THINGS_THAN_REMOVE_MISSING_VALUES}
protectedinherited

the goal of the DBRowGenerator (just remove missing values or not)

Definition at line 336 of file DBRowGenerator.h.

◆ nb_remaining_output_rows_

std::size_t gum::learning::DBRowGenerator::nb_remaining_output_rows_ {std::size_t(0)}
protectedinherited

the number of output rows still to retrieve through the generate method

Definition at line 325 of file DBRowGenerator.h.

325{std::size_t(0)};

◆ nodeId2columns_

template<typename GUM_SCALAR = double>
Bijection< NodeId, std::size_t > gum::learning::DBRowGeneratorWithBN< GUM_SCALAR >::nodeId2columns_
protected

the mapping betwen the BN's node ids and the database's columns

Definition at line 147 of file DBRowGeneratorWithBN.h.


The documentation for this class was generated from the following file: