![]() |
aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
|
#include <BNDatabaseGenerator.h>
Public Types | |
| enum class | DiscretizedLabelMode : char { INTERVAL , MEDIAN , RANDOM } |
Public Member Functions | |
Constructors / Destructors | |
| BNDatabaseGenerator (const BayesNet< GUM_SCALAR > &bn) | |
| default constructor | |
| ~BNDatabaseGenerator () | |
| destructor | |
Accessors / Modifiers | |
| double | drawSamples (Size nbSamples) |
| generate and stock database, returns log2likelihood using ProgressNotifier as notification | |
| double | drawSamples (Size nbSamples, const gum::Instantiation &evs, int timeout=300) |
| Generate and stock the part of the database compatible with the evidence, returns log2likelihood using ProgressNotifier as notification. | |
| void | setDiscretizedLabelModeRandom () |
| set the behaviour of sampling for discretized variable to uniformly draw double value | |
| void | setDiscretizedLabelModeMedian () |
| set the behaviour of sampling for discretized variable to deterministic select double median of intervalls | |
| void | setDiscretizedLabelModeInterval () |
| set the behaviour of sampling for discretized variable to select the label : "[min,max[" | |
| void | toCSV (std::string_view csvFileURL, bool useLabels=true, bool append=false, std::string csvSeparator=",", bool checkOnAppend=false) const |
| generates csv representing the generated database | |
| DatabaseTable | toDatabaseTable (bool useLabels=true) const |
| generates a DatabaseVectInRAM | |
| std::vector< std::vector< Idx > > | database () const |
| generates database according to bn into a std::vector | |
| Size | samplesNbRows () const |
| generate and stock database, returns log2likelihood using ProgressNotifier as notification | |
| Size | samplesNbCols () const |
| generate and stock database, returns log2likelihood using ProgressNotifier as notification | |
| Idx | samplesAt (Idx row, Idx col) const |
| generate and stock database, returns log2likelihood using ProgressNotifier as notification | |
| std::string | samplesLabelAt (Idx row, Idx col) const |
| generate and stock database, returns log2likelihood using ProgressNotifier as notification | |
| void | setVarOrder (const std::vector< Idx > &varOrder) |
| change columns order | |
| void | setVarOrder (const std::vector< std::string > &varOrder) |
| change columns order using variable names | |
| void | setVarOrderFromCSV (std::string_view csvFileURL, std::string_view csvSeparator=",") |
| change columns order according to a csv file | |
| void | setTopologicalVarOrder () |
| set columns in topoligical order | |
| void | setAntiTopologicalVarOrder () |
| set columns in antiTopoligical order | |
| void | setRandomVarOrder () |
| set columns in random order | |
| std::vector< Idx > | varOrder () const |
| returns variable order indexes | |
| std::vector< std::string > | varOrderNames () const |
| returns variable order. | |
| double | log2likelihood () const |
| returns log2Likelihood of generated samples | |
| const BayesNet< GUM_SCALAR > & | bn (void) |
| return const ref to the Bayes Net | |
Public Attributes | |
| Signaler< Size, double > | onProgress |
| Progression (percent) and time. | |
| Signaler< std::string_view > | onStop |
| with a possible explanation for stopping | |
Private Member Functions | |
| std::string | _label_ (const std::vector< Idx > &row, const DiscreteVariable &v, Idx i) const |
| return the final string for a label (taking into account the behavior for DiscretizedVariable) from a row | |
| std::vector< Idx > | _varOrderFromCSV_ (std::string_view csvFileURL, std::string_view csvSeparator=",") const |
| returns varOrder from a csv file | |
| std::vector< Idx > | _varOrderFromCSV_ (std::ifstream &csvFile, std::string_view csvSeparator=",") const |
| returns varOrder from a csv file | |
| BNDatabaseGenerator (const BNDatabaseGenerator &)=delete | |
| BNDatabaseGenerator (BNDatabaseGenerator &&)=delete | |
| BNDatabaseGenerator & | operator= (const BNDatabaseGenerator &)=delete |
| BNDatabaseGenerator & | operator= (BNDatabaseGenerator &&)=delete |
Private Attributes | |
| DiscretizedLabelMode | _discretizedLabelMode_ |
| const BayesNet< GUM_SCALAR > & | _bn_ |
| Bayesian network. | |
| Bijection< std::string, NodeId > | _names2ids_ |
| bijection nodes names | |
| Size | _nbVars_ |
| number of variables | |
| std::vector< std::vector< Idx > > | _database_ |
| generated database | |
| std::vector< Idx > | _varOrder_ |
| variable order in generated database | |
| bool | _drawnSamples_ = false |
| whether drawSamples has been already called. | |
| double | _log2likelihood_ = 0 |
| log2Likelihood of generated samples | |
Definition at line 103 of file BNDatabaseGenerator.h.
|
strong |
| Enumerator | |
|---|---|
| INTERVAL | |
| MEDIAN | |
| RANDOM | |
Definition at line 105 of file BNDatabaseGenerator.h.
|
explicit |
default constructor
Definition at line 58 of file BNDatabaseGenerator_tpl.h.
References BNDatabaseGenerator(), _bn_, _discretizedLabelMode_, _names2ids_, _nbVars_, _varOrder_, bn(), and RANDOM.
Referenced by BNDatabaseGenerator(), BNDatabaseGenerator(), BNDatabaseGenerator(), ~BNDatabaseGenerator(), operator=(), and operator=().
| gum::learning::BNDatabaseGenerator< GUM_SCALAR >::~BNDatabaseGenerator | ( | ) |
destructor
Definition at line 77 of file BNDatabaseGenerator_tpl.h.
References BNDatabaseGenerator().
|
privatedelete |
|
privatedelete |
|
private |
return the final string for a label (taking into account the behavior for DiscretizedVariable) from a row
Definition at line 296 of file BNDatabaseGenerator_tpl.h.
References _discretizedLabelMode_, gum::DISCRETIZED, INTERVAL, gum::DiscreteVariable::label(), MEDIAN, gum::DiscreteVariable::numerical(), RANDOM, and gum::DiscreteVariable::varType().
Referenced by samplesLabelAt(), and toDatabaseTable().
|
private |
returns varOrder from a csv file
Definition at line 491 of file BNDatabaseGenerator_tpl.h.
References _names2ids_, _nbVars_, and varOrder().
|
private |
returns varOrder from a csv file
Definition at line 474 of file BNDatabaseGenerator_tpl.h.
References _varOrderFromCSV_(), GUM_ERROR, and varOrder().
Referenced by _varOrderFromCSV_(), setVarOrderFromCSV(), and toCSV().
| const BayesNet< GUM_SCALAR > & gum::learning::BNDatabaseGenerator< GUM_SCALAR >::bn | ( | void | ) |
return const ref to the Bayes Net
Definition at line 521 of file BNDatabaseGenerator_tpl.h.
References _bn_.
Referenced by BNDatabaseGenerator().
| std::vector< std::vector< Idx > > gum::learning::BNDatabaseGenerator< GUM_SCALAR >::database | ( | ) | const |
generates database according to bn into a std::vector
returns database using specified data order
Definition at line 361 of file BNDatabaseGenerator_tpl.h.
References _database_, _drawnSamples_, _nbVars_, _varOrder_, and GUM_ERROR.
| double gum::learning::BNDatabaseGenerator< GUM_SCALAR >::drawSamples | ( | Size | nbSamples | ) |
generate and stock database, returns log2likelihood using ProgressNotifier as notification
draw instances from bn
Definition at line 83 of file BNDatabaseGenerator_tpl.h.
References drawSamples().
Referenced by drawSamples().
| double gum::learning::BNDatabaseGenerator< GUM_SCALAR >::drawSamples | ( | Size | nbSamples, |
| const gum::Instantiation & | evs, | ||
| int | timeout = 300 ) |
Generate and stock the part of the database compatible with the evidence, returns log2likelihood using ProgressNotifier as notification.
draw instances from bn
| nbSamples | the size of the filtered database. |
| evs | the evidence. |
| timeout | the maximum time in seconds to wait for the generation of the samples. If the timeout is reached, the function returns the log2likelihood of the generated samples. if timeout=0, no timeout are watched and the function may run indefinitely. |
Definition at line 90 of file BNDatabaseGenerator_tpl.h.
References _bn_, _database_, _drawnSamples_, _log2likelihood_, _nbVars_, gum::Instantiation::add(), gum::Instantiation::contains(), gum::Instantiation::empty(), gum::Instantiation::end(), GUM_EMIT1, GUM_EMIT2, gum::Instantiation::incVar(), gum::ProgressNotifier::onProgress, gum::ProgressNotifier::onStop, gum::randomProba(), gum::Timer::reset(), gum::Instantiation::setFirstVar(), gum::Instantiation::setLastVar(), gum::Timer::step(), and gum::Instantiation::val().
| double gum::learning::BNDatabaseGenerator< GUM_SCALAR >::log2likelihood | ( | ) | const |
returns log2Likelihood of generated samples
Definition at line 466 of file BNDatabaseGenerator_tpl.h.
References _drawnSamples_, _log2likelihood_, and GUM_ERROR.
|
privatedelete |
|
privatedelete |
| Idx gum::learning::BNDatabaseGenerator< GUM_SCALAR >::samplesAt | ( | Idx | row, |
| Idx | col ) const |
generate and stock database, returns log2likelihood using ProgressNotifier as notification
draw instances from bn
Definition at line 186 of file BNDatabaseGenerator_tpl.h.
References _database_, _drawnSamples_, _varOrder_, and GUM_ERROR.
| std::string gum::learning::BNDatabaseGenerator< GUM_SCALAR >::samplesLabelAt | ( | Idx | row, |
| Idx | col ) const |
generate and stock database, returns log2likelihood using ProgressNotifier as notification
draw instances from bn
Definition at line 192 of file BNDatabaseGenerator_tpl.h.
References _bn_, _database_, _drawnSamples_, _label_(), _varOrder_, and GUM_ERROR.
| Size gum::learning::BNDatabaseGenerator< GUM_SCALAR >::samplesNbCols | ( | ) | const |
generate and stock database, returns log2likelihood using ProgressNotifier as notification
draw instances from bn
Definition at line 179 of file BNDatabaseGenerator_tpl.h.
References _drawnSamples_, _nbVars_, and GUM_ERROR.
| Size gum::learning::BNDatabaseGenerator< GUM_SCALAR >::samplesNbRows | ( | ) | const |
generate and stock database, returns log2likelihood using ProgressNotifier as notification
draw instances from bn
Definition at line 172 of file BNDatabaseGenerator_tpl.h.
References _database_, _drawnSamples_, and GUM_ERROR.
| void gum::learning::BNDatabaseGenerator< GUM_SCALAR >::setAntiTopologicalVarOrder | ( | ) |
set columns in antiTopoligical order
set columns in antiTopological order
Definition at line 424 of file BNDatabaseGenerator_tpl.h.
References _bn_, _nbVars_, setVarOrder(), and varOrder().
| void gum::learning::BNDatabaseGenerator< GUM_SCALAR >::setDiscretizedLabelModeInterval | ( | ) |
set the behaviour of sampling for discretized variable to select the label : "[min,max["
Definition at line 209 of file BNDatabaseGenerator_tpl.h.
References _discretizedLabelMode_, and INTERVAL.
| void gum::learning::BNDatabaseGenerator< GUM_SCALAR >::setDiscretizedLabelModeMedian | ( | ) |
set the behaviour of sampling for discretized variable to deterministic select double median of intervalls
Definition at line 204 of file BNDatabaseGenerator_tpl.h.
References _discretizedLabelMode_, and MEDIAN.
| void gum::learning::BNDatabaseGenerator< GUM_SCALAR >::setDiscretizedLabelModeRandom | ( | ) |
set the behaviour of sampling for discretized variable to uniformly draw double value
Definition at line 199 of file BNDatabaseGenerator_tpl.h.
References _discretizedLabelMode_, and RANDOM.
| void gum::learning::BNDatabaseGenerator< GUM_SCALAR >::setRandomVarOrder | ( | ) |
set columns in random order
Definition at line 436 of file BNDatabaseGenerator_tpl.h.
References _bn_, gum::randomGenerator(), setVarOrder(), and varOrder().
| void gum::learning::BNDatabaseGenerator< GUM_SCALAR >::setTopologicalVarOrder | ( | ) |
set columns in topoligical order
set columns in Topological order
Definition at line 413 of file BNDatabaseGenerator_tpl.h.
References _bn_, _nbVars_, setVarOrder(), and varOrder().
| void gum::learning::BNDatabaseGenerator< GUM_SCALAR >::setVarOrder | ( | const std::vector< Idx > & | varOrder | ) |
change columns order
Definition at line 375 of file BNDatabaseGenerator_tpl.h.
References _nbVars_, _varOrder_, GUM_ERROR, and varOrder().
Referenced by setAntiTopologicalVarOrder(), setRandomVarOrder(), setTopologicalVarOrder(), setVarOrder(), and setVarOrderFromCSV().
| void gum::learning::BNDatabaseGenerator< GUM_SCALAR >::setVarOrder | ( | const std::vector< std::string > & | varOrder | ) |
change columns order using variable names
Definition at line 395 of file BNDatabaseGenerator_tpl.h.
References _names2ids_, setVarOrder(), and varOrder().
| void gum::learning::BNDatabaseGenerator< GUM_SCALAR >::setVarOrderFromCSV | ( | std::string_view | csvFileURL, |
| std::string_view | csvSeparator = "," ) |
change columns order according to a csv file
Definition at line 406 of file BNDatabaseGenerator_tpl.h.
References _varOrderFromCSV_(), and setVarOrder().
| void gum::learning::BNDatabaseGenerator< GUM_SCALAR >::toCSV | ( | std::string_view | csvFileURL, |
| bool | useLabels = true, | ||
| bool | append = false, | ||
| std::string | csvSeparator = ",", | ||
| bool | checkOnAppend = false ) const |
generates csv representing the generated database
generates database, and writes csv file
Definition at line 215 of file BNDatabaseGenerator_tpl.h.
References _bn_, _database_, _discretizedLabelMode_, _drawnSamples_, _varOrder_, _varOrderFromCSV_(), gum::DISCRETIZED, GUM_ERROR, INTERVAL, MEDIAN, RANDOM, and varOrder().
| DatabaseTable gum::learning::BNDatabaseGenerator< GUM_SCALAR >::toDatabaseTable | ( | bool | useLabels = true | ) | const |
generates a DatabaseVectInRAM
Definition at line 313 of file BNDatabaseGenerator_tpl.h.
References _bn_, _database_, _drawnSamples_, _label_(), _names2ids_, _nbVars_, _varOrder_, gum::learning::DISCRETE, gum::learning::DBTranslator::getValType(), GUM_ERROR, gum::learning::DatabaseTable::insertRow(), gum::learning::DatabaseTable::insertTranslator(), and gum::learning::DatabaseTable::translator().
| std::vector< Idx > gum::learning::BNDatabaseGenerator< GUM_SCALAR >::varOrder | ( | ) | const |
returns variable order indexes
Definition at line 448 of file BNDatabaseGenerator_tpl.h.
References _varOrder_.
Referenced by _varOrderFromCSV_(), _varOrderFromCSV_(), setAntiTopologicalVarOrder(), setRandomVarOrder(), setTopologicalVarOrder(), setVarOrder(), setVarOrder(), and toCSV().
| std::vector< std::string > gum::learning::BNDatabaseGenerator< GUM_SCALAR >::varOrderNames | ( | ) | const |
returns variable order.
Definition at line 454 of file BNDatabaseGenerator_tpl.h.
References _names2ids_, _nbVars_, and _varOrder_.
|
private |
Bayesian network.
Definition at line 219 of file BNDatabaseGenerator.h.
Referenced by BNDatabaseGenerator(), bn(), drawSamples(), samplesLabelAt(), setAntiTopologicalVarOrder(), setRandomVarOrder(), setTopologicalVarOrder(), toCSV(), and toDatabaseTable().
|
private |
generated database
Definition at line 228 of file BNDatabaseGenerator.h.
Referenced by database(), drawSamples(), samplesAt(), samplesLabelAt(), samplesNbRows(), toCSV(), and toDatabaseTable().
|
private |
Definition at line 217 of file BNDatabaseGenerator.h.
Referenced by BNDatabaseGenerator(), _label_(), setDiscretizedLabelModeInterval(), setDiscretizedLabelModeMedian(), setDiscretizedLabelModeRandom(), and toCSV().
|
private |
whether drawSamples has been already called.
Definition at line 234 of file BNDatabaseGenerator.h.
Referenced by database(), drawSamples(), log2likelihood(), samplesAt(), samplesLabelAt(), samplesNbCols(), samplesNbRows(), toCSV(), and toDatabaseTable().
|
private |
log2Likelihood of generated samples
Definition at line 237 of file BNDatabaseGenerator.h.
Referenced by drawSamples(), and log2likelihood().
|
private |
bijection nodes names
Definition at line 222 of file BNDatabaseGenerator.h.
Referenced by BNDatabaseGenerator(), _varOrderFromCSV_(), setVarOrder(), toDatabaseTable(), and varOrderNames().
|
private |
number of variables
Definition at line 225 of file BNDatabaseGenerator.h.
Referenced by BNDatabaseGenerator(), _varOrderFromCSV_(), database(), drawSamples(), samplesNbCols(), setAntiTopologicalVarOrder(), setTopologicalVarOrder(), setVarOrder(), toDatabaseTable(), and varOrderNames().
|
private |
variable order in generated database
Definition at line 231 of file BNDatabaseGenerator.h.
Referenced by BNDatabaseGenerator(), database(), samplesAt(), samplesLabelAt(), setVarOrder(), toCSV(), toDatabaseTable(), varOrder(), and varOrderNames().
Progression (percent) and time.
Definition at line 69 of file progressNotification.h.
Referenced by gum::learning::BNDatabaseGenerator< GUM_SCALAR >::drawSamples().
|
inherited |
with a possible explanation for stopping
Definition at line 72 of file progressNotification.h.
Referenced by gum::learning::BNDatabaseGenerator< GUM_SCALAR >::drawSamples().