![]() |
aGrUM
0.20.2
a C++ library for (probabilistic) graphical models
|
A pack of learning algorithms that can easily be used. More...
#include <BNLearner.h>
Public Attributes | |
Signaler3< Size, double, double > | onProgress |
Progression, error and time. More... | |
Signaler1< std::string > | onStop |
Criteria messageApproximationScheme. More... | |
Public Member Functions | |
BayesNet< GUM_SCALAR > | learnBN () |
learn a Bayes Net from a file (must have read the db before) More... | |
BayesNet< GUM_SCALAR > | learnParameters (const DAG &dag, bool take_into_account_score=true) |
learns a BN (its parameters) when its structure is known More... | |
BayesNet< GUM_SCALAR > | learnParameters (bool take_into_account_score=true) |
void | setAprioriWeight__ (double weight) |
sets the apriori weight More... | |
void | setMandatoryArcs (const ArcSet &set) |
assign a set of forbidden arcs More... | |
Constructors / Destructors | |
BNLearner (const std::string &filename, const std::vector< std::string > &missing_symbols={"?"}) | |
default constructor More... | |
BNLearner (const DatabaseTable<> &db) | |
default constructor More... | |
BNLearner (const std::string &filename, const gum::BayesNet< GUM_SCALAR > &src, const std::vector< std::string > &missing_symbols={"?"}) | |
Read the database file for the score / parameter estimation and var names. More... | |
BNLearner (const BNLearner &) | |
copy constructor More... | |
BNLearner (BNLearner &&) | |
move constructor More... | |
virtual | ~BNLearner () |
destructor More... | |
Operators | |
BNLearner & | operator= (const BNLearner &) |
copy operator More... | |
BNLearner & | operator= (BNLearner &&) |
move operator More... | |
Accessors / Modifiers | |
DAG | learnDAG () |
learn a structure from a file (must have read the db before) More... | |
MixedGraph | learnMixedStructure () |
learn a partial structure from a file (must have read the db before and must have selected miic or 3off2) More... | |
void | setInitialDAG (const DAG &) |
sets an initial DAG structure More... | |
const std::vector< std::string > & | names () const |
returns the names of the variables in the database More... | |
const std::vector< std::size_t > & | domainSizes () const |
returns the domain sizes of the variables in the database More... | |
Size | domainSize (NodeId var) const |
learn a structure from a file (must have read the db before) More... | |
Size | domainSize (const std::string &var) const |
learn a structure from a file (must have read the db before) More... | |
NodeId | idFromName (const std::string &var_name) const |
returns the node id corresponding to a variable name More... | |
const DatabaseTable & | database () const |
returns the database used by the BNLearner More... | |
void | setDatabaseWeight (const double new_weight) |
assign a weight to all the rows of the learning database so that the sum of their weights is equal to new_weight More... | |
void | setRecordWeight (const std::size_t i, const double weight) |
sets the weight of the ith record of the database More... | |
double | recordWeight (const std::size_t i) const |
returns the weight of the ith record More... | |
double | databaseWeight () const |
returns the weight of the whole database More... | |
const std::string & | nameFromId (NodeId id) const |
returns the variable name corresponding to a given node id More... | |
template<template< typename > class XALLOC> | |
void | useDatabaseRanges (const std::vector< std::pair< std::size_t, std::size_t >, XALLOC< std::pair< std::size_t, std::size_t > > > &new_ranges) |
use a new set of database rows' ranges to perform learning More... | |
void | clearDatabaseRanges () |
reset the ranges to the one range corresponding to the whole database More... | |
const std::vector< std::pair< std::size_t, std::size_t > > & | databaseRanges () const |
returns the current database rows' ranges used for learning More... | |
std::pair< std::size_t, std::size_t > | useCrossValidationFold (const std::size_t learning_fold, const std::size_t k_fold) |
sets the ranges of rows to be used for cross-validation learning More... | |
std::pair< double, double > | chi2 (const NodeId id1, const NodeId id2, const std::vector< NodeId > &knowing={}) |
Return the <statistic,pvalue> pair for chi2 test in the database. More... | |
std::pair< double, double > | chi2 (const std::string &name1, const std::string &name2, const std::vector< std::string > &knowing={}) |
Return the <statistic,pvalue> pair for the BNLearner. More... | |
std::pair< double, double > | G2 (const NodeId id1, const NodeId id2, const std::vector< NodeId > &knowing={}) |
Return the <statistic,pvalue> pair for for G2 test in the database. More... | |
std::pair< double, double > | G2 (const std::string &name1, const std::string &name2, const std::vector< std::string > &knowing={}) |
Return the <statistic,pvalue> pair for for G2 test in the database. More... | |
double | logLikelihood (const std::vector< NodeId > &vars, const std::vector< NodeId > &knowing={}) |
Return the loglikelihood of vars in the base, conditioned by knowing for the BNLearner. More... | |
double | logLikelihood (const std::vector< std::string > &vars, const std::vector< std::string > &knowing={}) |
Return the loglikelihood of vars in the base, conditioned by knowing for the BNLearner. More... | |
std::vector< double > | rawPseudoCount (const std::vector< NodeId > &vars) |
Return the pseudoconts ofNodeIds vars in the base in a raw array. More... | |
std::vector< double > | rawPseudoCount (const std::vector< std::string > &vars) |
Return the pseudoconts of vars in the base in a raw array. More... | |
Size | nbCols () const |
Size | nbRows () const |
void | useEM (const double epsilon) |
use The EM algorithm to learn paramters More... | |
bool | hasMissingValues () const |
returns true if the learner's database has missing values More... | |
Score selection | |
void | useScoreAIC () |
indicate that we wish to use an AIC score More... | |
void | useScoreBD () |
indicate that we wish to use a BD score More... | |
void | useScoreBDeu () |
indicate that we wish to use a BDeu score More... | |
void | useScoreBIC () |
indicate that we wish to use a BIC score More... | |
void | useScoreK2 () |
indicate that we wish to use a K2 score More... | |
void | useScoreLog2Likelihood () |
indicate that we wish to use a Log2Likelihood score More... | |
A priori selection / parameterization | |
void | useNoApriori () |
use no apriori More... | |
void | useAprioriBDeu (double weight=1) |
use the BDeu apriori More... | |
void | useAprioriSmoothing (double weight=1) |
use the apriori smoothing More... | |
void | useAprioriDirichlet (const std::string &filename, double weight=1) |
use the Dirichlet apriori More... | |
std::string | checkScoreAprioriCompatibility () |
checks whether the current score and apriori are compatible More... | |
Learning algorithm selection | |
void | useGreedyHillClimbing () |
indicate that we wish to use a greedy hill climbing algorithm More... | |
void | useLocalSearchWithTabuList (Size tabu_size=100, Size nb_decrease=2) |
indicate that we wish to use a local search with tabu list More... | |
void | useK2 (const Sequence< NodeId > &order) |
indicate that we wish to use K2 More... | |
void | useK2 (const std::vector< NodeId > &order) |
indicate that we wish to use K2 More... | |
void | use3off2 () |
indicate that we wish to use 3off2 More... | |
void | useMIIC () |
indicate that we wish to use MIIC More... | |
3off2/MIIC parameterization and specific results | |
void | useNML () |
indicate that we wish to use the NML correction for 3off2 More... | |
void | useMDL () |
indicate that we wish to use the MDL correction for 3off2 More... | |
void | useNoCorr () |
indicate that we wish to use the NoCorr correction for 3off2 More... | |
const std::vector< Arc > | latentVariables () const |
get the list of arcs hiding latent variables More... | |
Accessors / Modifiers for adding constraints on learning | |
void | setMaxIndegree (Size max_indegree) |
sets the max indegree More... | |
void | setSliceOrder (const NodeProperty< NodeId > &slice_order) |
sets a partial order on the nodes More... | |
void | setSliceOrder (const std::vector< std::vector< std::string > > &slices) |
sets a partial order on the nodes More... | |
void | setForbiddenArcs (const ArcSet &set) |
assign a set of forbidden arcs More... | |
assign a new forbidden arc | |
void | addForbiddenArc (const Arc &arc) |
void | addForbiddenArc (const NodeId tail, const NodeId head) |
void | addForbiddenArc (const std::string &tail, const std::string &head) |
void | addMandatoryArc (const Arc &arc) |
void | addMandatoryArc (const NodeId tail, const NodeId head) |
void | addMandatoryArc (const std::string &tail, const std::string &head) |
remove a forbidden arc | |
void | eraseForbiddenArc (const Arc &arc) |
void | eraseForbiddenArc (const NodeId tail, const NodeId head) |
void | eraseForbiddenArc (const std::string &tail, const std::string &head) |
void | eraseMandatoryArc (const Arc &arc) |
void | eraseMandatoryArc (const NodeId tail, const NodeId head) |
void | eraseMandatoryArc (const std::string &tail, const std::string &head) |
void | setPossibleEdges (const EdgeSet &set) |
assign a set of forbidden edges More... | |
void | setPossibleSkeleton (const UndiGraph &skeleton) |
assign a set of forbidden edges More... | |
assign a new possible edge | |
| |
void | addPossibleEdge (const Edge &edge) |
void | addPossibleEdge (const NodeId tail, const NodeId head) |
void | addPossibleEdge (const std::string &tail, const std::string &head) |
remove a possible edge | |
void | erasePossibleEdge (const Edge &edge) |
void | erasePossibleEdge (const NodeId tail, const NodeId head) |
void | erasePossibleEdge (const std::string &tail, const std::string &head) |
redistribute signals AND implemenation of interface | |
INLINE void | setCurrentApproximationScheme (const ApproximationScheme *approximationScheme) |
{@ /// distribute signals More... | |
INLINE void | distributeProgress (const ApproximationScheme *approximationScheme, Size pourcent, double error, double time) |
{@ /// distribute signals More... | |
INLINE void | distributeStop (const ApproximationScheme *approximationScheme, std::string message) |
distribute signals More... | |
void | setEpsilon (double eps) |
Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)| If the criterion was disabled it will be enabled. More... | |
double | epsilon () const |
Get the value of epsilon. More... | |
void | disableEpsilon () |
Disable stopping criterion on epsilon. More... | |
void | enableEpsilon () |
Enable stopping criterion on epsilon. More... | |
bool | isEnabledEpsilon () const |
void | setMinEpsilonRate (double rate) |
Given that we approximate f(t), stopping criterion on d/dt(|f(t+1)-f(t)|) If the criterion was disabled it will be enabled. More... | |
double | minEpsilonRate () const |
Get the value of the minimal epsilon rate. More... | |
void | disableMinEpsilonRate () |
Disable stopping criterion on epsilon rate. More... | |
void | enableMinEpsilonRate () |
Enable stopping criterion on epsilon rate. More... | |
bool | isEnabledMinEpsilonRate () const |
void | setMaxIter (Size max) |
stopping criterion on number of iterationsIf the criterion was disabled it will be enabled More... | |
Size | maxIter () const |
void | disableMaxIter () |
Disable stopping criterion on max iterations. More... | |
void | enableMaxIter () |
Enable stopping criterion on max iterations. More... | |
bool | isEnabledMaxIter () const |
void | setMaxTime (double timeout) |
stopping criterion on timeout If the criterion was disabled it will be enabled More... | |
double | maxTime () const |
returns the timeout (in seconds) More... | |
double | currentTime () const |
get the current running time in second (double) More... | |
void | disableMaxTime () |
Disable stopping criterion on timeout. More... | |
void | enableMaxTime () |
stopping criterion on timeout If the criterion was disabled it will be enabled More... | |
bool | isEnabledMaxTime () const |
void | setPeriodSize (Size p) |
how many samples between 2 stopping isEnableds More... | |
Size | periodSize () const |
how many samples between 2 stopping isEnableds More... | |
void | setVerbosity (bool v) |
verbosity More... | |
bool | verbosity () const |
verbosity More... | |
ApproximationSchemeSTATE | stateApproximationScheme () const |
history More... | |
Size | nbrIterations () const |
const std::vector< double > & | history () const |
Getters and setters | |
std::string | messageApproximationScheme () const |
Returns the approximation scheme message. More... | |
Protected Member Functions | |
void | createApriori__ () |
create the apriori used for learning More... | |
void | createScore__ () |
create the score used for learning More... | |
ParamEstimator * | createParamEstimator__ (DBRowGeneratorParser<> &parser, bool take_into_account_score=true) |
create the parameter estimator used for learning More... | |
DAG | learnDAG__ () |
returns the DAG learnt More... | |
MixedGraph | prepare_miic_3off2__ () |
prepares the initial graph for 3off2 or miic More... | |
const std::string & | getAprioriType__ () const |
returns the type (as a string) of a given apriori More... | |
void | createCorrectedMutualInformation__ () |
create the Corrected Mutual Information instance for Miic/3off2 More... | |
Static Protected Member Functions | |
static DatabaseTable | readFile__ (const std::string &filename, const std::vector< std::string > &missing_symbols) |
reads a file and returns a databaseVectInRam More... | |
static void | checkFileName__ (const std::string &filename) |
checks whether the extension of a CSV filename is correct More... | |
A pack of learning algorithms that can easily be used.
The pack currently contains K2, GreedyHillClimbing and LocalSearchWithTabuList
Definition at line 59 of file BNLearner.h.
|
stronginherited |
an enumeration to select easily the learning algorithm to use
Enumerator | |
---|---|
K2 | |
GREEDY_HILL_CLIMBING | |
LOCAL_SEARCH_WITH_TABU_LIST | |
MIIC_THREE_OFF_TWO |
Definition at line 135 of file genericBNLearner.h.
|
stronginherited |
The different state of an approximation scheme.
Enumerator | |
---|---|
Undefined | |
Continue | |
Epsilon | |
Rate | |
Limit | |
TimeLimit | |
Stopped |
Definition at line 64 of file IApproximationSchemeConfiguration.h.
|
stronginherited |
an enumeration to select the apriori
Enumerator | |
---|---|
NO_APRIORI | |
SMOOTHING | |
DIRICHLET_FROM_DATABASE | |
BDEU |
Definition at line 126 of file genericBNLearner.h.
|
stronginherited |
an enumeration to select the type of parameter estimation we shall apply
Enumerator | |
---|---|
ML |
Definition at line 122 of file genericBNLearner.h.
|
stronginherited |
an enumeration enabling to select easily the score we wish to use
Enumerator | |
---|---|
AIC | |
BD | |
BDeu | |
BIC | |
K2 | |
LOG2LIKELIHOOD |
Definition at line 110 of file genericBNLearner.h.
gum::learning::BNLearner< GUM_SCALAR >::BNLearner | ( | const std::string & | filename, |
const std::vector< std::string > & | missing_symbols = {"?"} |
||
) |
default constructor
read the database file for the score / parameter estimation and var names
gum::learning::BNLearner< GUM_SCALAR >::BNLearner | ( | const DatabaseTable<> & | db | ) |
default constructor
read the database file for the score / parameter estimation and var names
gum::learning::BNLearner< GUM_SCALAR >::BNLearner | ( | const std::string & | filename, |
const gum::BayesNet< GUM_SCALAR > & | src, | ||
const std::vector< std::string > & | missing_symbols = {"?"} |
||
) |
Read the database file for the score / parameter estimation and var names.
If modalities = { 1 -> {True, False, Big} }, then the node of id 1 in the BN will have 3 modalities, the first one being True, the second one being False, and the third bein Big.
A parsing of the database will allow to determine which ones are really necessary and will keep them in the order specified by the user (NodeProperty modalities). If parse_database is set to false (the default), then the modalities specified by the user will be considered as being exactly those of the variables of the BN (as a consequence, if we find other values in the database, an exception will be raised during learning).
filename | The file to learn from. |
modalities | indicate for some nodes (not necessarily all the nodes of the BN) which modalities they should have and in which order these modalities should be stored into the nodes. |
parse_database | if true, the modalities specified by the user will be considered as a superset of the modalities of the variables. Wrapper for BNLearner (filename,modalities,parse_database) using a bn to find those modalities and nodeids. |
gum::learning::BNLearner< GUM_SCALAR >::BNLearner | ( | const BNLearner< GUM_SCALAR > & | ) |
copy constructor
gum::learning::BNLearner< GUM_SCALAR >::BNLearner | ( | BNLearner< GUM_SCALAR > && | ) |
move constructor
|
virtual |
destructor
|
inherited |
Definition at line 358 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 368 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 380 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 397 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 419 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 407 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 319 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 329 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 341 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
staticprotectedinherited |
checks whether the extension of a CSV filename is correct
Definition at line 414 of file genericBNLearner.cpp.
|
inherited |
checks whether the current score and apriori are compatible
Definition at line 871 of file genericBNLearner.cpp.
|
inherited |
Return the <statistic,pvalue> pair for chi2 test in the database.
id1 | first variable |
id2 | second variable |
knowing | list of observed variables |
Definition at line 948 of file genericBNLearner.cpp.
|
inherited |
Return the <statistic,pvalue> pair for the BNLearner.
id1 | first variable |
id2 | second variable |
knowing | list of observed variables |
Definition at line 960 of file genericBNLearner.cpp.
|
inherited |
reset the ranges to the one range corresponding to the whole database
Definition at line 554 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
protectedinherited |
create the apriori used for learning
Definition at line 465 of file genericBNLearner.cpp.
|
protectedinherited |
create the Corrected Mutual Information instance for Miic/3off2
Definition at line 666 of file genericBNLearner.cpp.
|
protectedinherited |
create the parameter estimator used for learning
Definition at line 572 of file genericBNLearner.cpp.
|
protectedinherited |
create the score used for learning
Definition at line 514 of file genericBNLearner.cpp.
|
inlinevirtualinherited |
get the current running time in second (double)
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1059 of file genericBNLearner.h.
|
inherited |
returns the database used by the BNLearner
Definition at line 557 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
returns the current database rows' ranges used for learning
Definition at line 549 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
returns the weight of the whole database
Definition at line 172 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
Disable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 924 of file genericBNLearner.h.
|
inlinevirtualinherited |
Disable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1014 of file genericBNLearner.h.
|
inlinevirtualinherited |
Disable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1067 of file genericBNLearner.h.
|
inlinevirtualinherited |
Disable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 970 of file genericBNLearner.h.
|
inlineinherited |
{@ /// distribute signals
Definition at line 886 of file genericBNLearner.h.
|
inlineinherited |
distribute signals
Definition at line 896 of file genericBNLearner.h.
learn a structure from a file (must have read the db before)
Definition at line 539 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
learn a structure from a file (must have read the db before)
Definition at line 543 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
returns the domain sizes of the variables in the database
Definition at line 534 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
Enable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 932 of file genericBNLearner.h.
|
inlinevirtualinherited |
Enable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1021 of file genericBNLearner.h.
|
inlinevirtualinherited |
stopping criterion on timeout If the criterion was disabled it will be enabled
OutOfLowerBound | if timeout<=0.0 timeout is time in second (double). |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1073 of file genericBNLearner.h.
|
inlinevirtualinherited |
Enable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 977 of file genericBNLearner.h.
|
inlinevirtualinherited |
Get the value of epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 916 of file genericBNLearner.h.
|
inherited |
Definition at line 363 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 374 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 386 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 402 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 425 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 413 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 324 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 335 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 347 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Return the <statistic,pvalue> pair for for G2 test in the database.
id1 | first variable |
id2 | second variable |
knowing | list of observed variables |
Definition at line 973 of file genericBNLearner.cpp.
|
inherited |
Return the <statistic,pvalue> pair for for G2 test in the database.
id1 | first variable |
id2 | second variable |
knowing | list of observed variables |
Definition at line 984 of file genericBNLearner.cpp.
|
protectedinherited |
returns the type (as a string) of a given apriori
Definition at line 506 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
returns true if the learner's database has missing values
Definition at line 305 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
OperationNotAllowed | if scheme not performed or verbosity=false |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1143 of file genericBNLearner.h.
|
inherited |
returns the node id corresponding to a variable name
MissingVariableInDatabase | if a variable of the BN is not found in the database. |
Definition at line 146 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 941 of file genericBNLearner.h.
|
inlinevirtualinherited |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1029 of file genericBNLearner.h.
|
inlinevirtualinherited |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1081 of file genericBNLearner.h.
|
inlinevirtualinherited |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 985 of file genericBNLearner.h.
|
private |
read the first line of a file to find column names
|
inherited |
get the list of arcs hiding latent variables
OperationNotAllowed | when 3off2 is not the selected algorithm |
Definition at line 265 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
BayesNet< GUM_SCALAR > gum::learning::BNLearner< GUM_SCALAR >::learnBN | ( | ) |
learn a Bayes Net from a file (must have read the db before)
|
inherited |
learn a structure from a file (must have read the db before)
Definition at line 658 of file genericBNLearner.cpp.
|
protectedinherited |
returns the DAG learnt
Definition at line 694 of file genericBNLearner.cpp.
|
inherited |
learn a partial structure from a file (must have read the db before and must have selected miic or 3off2)
Definition at line 640 of file genericBNLearner.cpp.
BayesNet< GUM_SCALAR > gum::learning::BNLearner< GUM_SCALAR >::learnParameters | ( | const DAG & | dag, |
bool | take_into_account_score = true |
||
) |
learns a BN (its parameters) when its structure is known
dag | the structure of the Bayesian network |
take_into_account_score | The dag passed in argument may have been learnt from a structure learning. In this case, if the score used to learn the structure has an implicit apriori (like K2 which has a 1-smoothing apriori), it is important to also take into account this implicit apriori for parameter learning. By default, if a score exists, we will learn parameters by taking into account the apriori specified by methods useAprioriXXX () + the implicit apriori of the score, else we just take into account the apriori specified by useAprioriXXX () |
BayesNet< GUM_SCALAR > gum::learning::BNLearner< GUM_SCALAR >::learnParameters | ( | bool | take_into_account_score = true | ) |
take_into_account_score | The dag of the BN which was passed in argument to the BNLearner may have been learnt from a structure learning. In this case, if the score used to learn the structure has an implicit apriori (like K2 which has a 1-smoothing apriori), it is important to also take into account this implicit apriori for parameter learning. By default, if a score exists, we will learn parameters by taking into account the apriori specified by methods useAprioriXXX () + the implicit apriori of the score, else we just take into account the apriori specified by useAprioriXXX () |
MissingVariableInDatabase | if a variable of the BN is not found in the database. |
UnknownLabelInDatabase | if a label is found in the databast that do not correpond to the variable. |
|
inherited |
Return the loglikelihood of vars in the base, conditioned by knowing for the BNLearner.
vars | a vector of NodeIds |
knowing | an optional vector of conditioning NodeIds |
Definition at line 996 of file genericBNLearner.cpp.
|
inherited |
Return the loglikelihood of vars in the base, conditioned by knowing for the BNLearner.
vars | a vector of name of rows |
knowing | an optional vector of conditioning rows |
Definition at line 1015 of file genericBNLearner.cpp.
|
inlinevirtualinherited |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1006 of file genericBNLearner.h.
|
inlinevirtualinherited |
returns the timeout (in seconds)
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1051 of file genericBNLearner.h.
|
inherited |
Returns the approximation scheme message.
Definition at line 39 of file IApproximationSchemeConfiguration_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inlinevirtualinherited |
Get the value of the minimal epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 962 of file genericBNLearner.h.
|
inherited |
returns the variable name corresponding to a given node id
Definition at line 151 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
returns the names of the variables in the database
Definition at line 528 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 561 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
OperationNotAllowed | if scheme not performed |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1135 of file genericBNLearner.h.
|
inherited |
Definition at line 565 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
BNLearner& gum::learning::BNLearner< GUM_SCALAR >::operator= | ( | const BNLearner< GUM_SCALAR > & | ) |
copy operator
BNLearner& gum::learning::BNLearner< GUM_SCALAR >::operator= | ( | BNLearner< GUM_SCALAR > && | ) |
move operator
|
inlinevirtualinherited |
how many samples between 2 stopping isEnableds
OutOfLowerBound | if p<1 |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1099 of file genericBNLearner.h.
|
protectedinherited |
prepares the initial graph for 3off2 or miic
Definition at line 610 of file genericBNLearner.cpp.
|
inherited |
Return the pseudoconts ofNodeIds vars in the base in a raw array.
vars | a vector of |
Definition at line 1034 of file genericBNLearner.cpp.
|
inherited |
Return the pseudoconts of vars in the base in a raw array.
vars | a vector of name |
Definition at line 1046 of file genericBNLearner.cpp.
|
staticprotectedinherited |
reads a file and returns a databaseVectInRam
Definition at line 438 of file genericBNLearner.cpp.
|
inherited |
returns the weight of the ith record
OutOfBounds | if i is outside the set of indices of the records |
Definition at line 167 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
sets the apriori weight
Definition at line 450 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlineinherited |
{@ /// distribute signals
Definition at line 880 of file genericBNLearner.h.
|
inherited |
assign a weight to all the rows of the learning database so that the sum of their weights is equal to new_weight
assign new weight to the rows of the learning database
Definition at line 156 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)| If the criterion was disabled it will be enabled.
OutOfLowerBound | if eps<0 |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 908 of file genericBNLearner.h.
|
inherited |
assign a set of forbidden arcs
Definition at line 353 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
sets an initial DAG structure
Definition at line 177 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
assign a set of forbidden arcs
Definition at line 392 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
sets the max indegree
Definition at line 218 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
stopping criterion on number of iterationsIf the criterion was disabled it will be enabled
max | The maximum number of iterations |
OutOfLowerBound | if max<=1 |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 998 of file genericBNLearner.h.
|
inlinevirtualinherited |
stopping criterion on timeout If the criterion was disabled it will be enabled
OutOfLowerBound | if timeout<=0.0 timeout is time in second (double). |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1043 of file genericBNLearner.h.
|
inlinevirtualinherited |
Given that we approximate f(t), stopping criterion on d/dt(|f(t+1)-f(t)|) If the criterion was disabled it will be enabled.
OutOfLowerBound | if rate<0 |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 954 of file genericBNLearner.h.
|
inlinevirtualinherited |
how many samples between 2 stopping isEnableds
OutOfLowerBound | if p<1 |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1092 of file genericBNLearner.h.
|
inherited |
assign a set of forbidden edges
Definition at line 310 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
assign a set of forbidden edges
Definition at line 314 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
sets the weight of the ith record of the database
assign new weight to the ith row of the learning database
OutOfBounds | if i is outside the set of indices of the records or if the weight is negative |
Definition at line 161 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
sets a partial order on the nodes
slice_order | a NodeProperty given the rank (priority) of nodes in the partial order |
Definition at line 432 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
sets a partial order on the nodes
slices | the list of list of variable names |
Definition at line 436 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
verbosity
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1109 of file genericBNLearner.h.
|
inlinevirtualinherited |
history
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1127 of file genericBNLearner.h.
|
inherited |
indicate that we wish to use 3off2
Definition at line 223 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
use the BDeu apriori
The BDeu apriori adds weight to all the cells of the countings tables. In other words, it adds weight rows in the database with equally probable values.
Definition at line 493 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
use the Dirichlet apriori
Definition at line 478 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
use the apriori smoothing
weight | pass in argument a weight if you wish to assign a weight to the smoothing, else the current weight of the genericBNLearner will be used. |
Definition at line 466 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
sets the ranges of rows to be used for cross-validation learning
When applied on (x,k), the method indicates to the subsequent learnings that they should be performed on the xth fold in a k-fold cross-validation context. For instance, if a database has 1000 rows, and if we perform a 10-fold cross-validation, then, the first learning fold (learning_fold=0) corresponds to rows interval [100,1000) and the test dataset corresponds to [0,100). The second learning fold (learning_fold=1) is [0,100) U [200,1000) and the corresponding test dataset is [100,200).
learning_fold | a number indicating the set of rows used for learning. If N denotes the size of the database, and k_fold represents the number of folds in the cross validation, then the set of rows used for testing is [learning_fold * N / k_fold, (learning_fold+1) * N / k_fold) and the learning database is the complement in the database |
k_fold | the value of "k" in k-fold cross validation |
OutOfBounds | is raised if k_fold is equal to 0 or learning_fold is greater than or eqal to k_fold, or if k_fold is greater than or equal to the size of the database. |
Definition at line 902 of file genericBNLearner.cpp.
|
inherited |
use a new set of database rows' ranges to perform learning
ranges | a set of pairs {(X1,Y1),...,(Xn,Yn)} of database's rows indices. The subsequent learnings are then performed only on the union of the rows [Xi,Yi), i in {1,...,n}. This is useful, e.g, when performing cross validation tasks, in which part of the database should be ignored. An empty set of ranges is equivalent to an interval [X,Y) ranging over the whole database. |
Definition at line 101 of file genericBNLearner_tpl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
use The EM algorithm to learn paramters
if epsilon=0, EM is not used
Definition at line 300 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use a greedy hill climbing algorithm
Definition at line 287 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
indicate that we wish to use K2
Definition at line 275 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use K2
Definition at line 281 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use a local search with tabu list
tabu_size | indicate the size of the tabu list |
nb_decrease | indicate the max number of changes decreasing the score consecutively that we allow to apply |
Definition at line 292 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use the MDL correction for 3off2
OperationNotAllowed | when 3off2 is not the selected algorithm |
Definition at line 245 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use MIIC
Definition at line 229 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use the NML correction for 3off2
OperationNotAllowed | when 3off2 is not the selected algorithm |
Definition at line 235 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
use no apriori
Definition at line 460 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use the NoCorr correction for 3off2
OperationNotAllowed | when 3off2 is not the selected algorithm |
Definition at line 255 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use an AIC score
Definition at line 182 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use a BD score
Definition at line 188 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use a BDeu score
Definition at line 194 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use a BIC score
Definition at line 200 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use a K2 score
Definition at line 206 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use a Log2Likelihood score
Definition at line 212 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
verbosity
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1116 of file genericBNLearner.h.
|
protectedinherited |
the apriori used
Definition at line 773 of file genericBNLearner.h.
|
protectedinherited |
the database used by the Dirichlet a priori
Definition at line 827 of file genericBNLearner.h.
|
protectedinherited |
the filename for the Dirichlet a priori, if any
Definition at line 830 of file genericBNLearner.h.
|
protectedinherited |
the a priori selected for the score and parameters
Definition at line 770 of file genericBNLearner.h.
|
protectedinherited |
the weight of the apriori
Definition at line 778 of file genericBNLearner.h.
|
protectedinherited |
the constraint on forbidden arcs
Definition at line 790 of file genericBNLearner.h.
|
protectedinherited |
the constraint for indegrees
Definition at line 784 of file genericBNLearner.h.
|
protectedinherited |
the constraint on forbidden arcs
Definition at line 796 of file genericBNLearner.h.
|
protectedinherited |
the constraint on possible Edges
Definition at line 793 of file genericBNLearner.h.
|
protectedinherited |
the constraint for 2TBNs
Definition at line 781 of file genericBNLearner.h.
|
protectedinherited |
the constraint for tabu lists
Definition at line 787 of file genericBNLearner.h.
|
protectedinherited |
Definition at line 836 of file genericBNLearner.h.
|
protectedinherited |
the parametric EM
Definition at line 812 of file genericBNLearner.h.
|
protectedinherited |
epsilon for EM. if espilon=0.0 : no EM
Definition at line 764 of file genericBNLearner.h.
|
protectedinherited |
the greedy hill climbing algorithm
Definition at line 815 of file genericBNLearner.h.
|
protectedinherited |
an initial DAG given to learners
Definition at line 833 of file genericBNLearner.h.
|
protectedinherited |
the K2 algorithm
Definition at line 802 of file genericBNLearner.h.
|
protectedinherited |
the penalty used in 3off2
Definition at line 808 of file genericBNLearner.h.
|
protectedinherited |
the local search with tabu list algorithm
Definition at line 818 of file genericBNLearner.h.
|
protectedinherited |
the 3off2 algorithm
Definition at line 805 of file genericBNLearner.h.
|
protectedinherited |
the selected correction for 3off2 and miic
Definition at line 767 of file genericBNLearner.h.
|
protectedinherited |
Definition at line 775 of file genericBNLearner.h.
Progression, error and time.
Definition at line 58 of file IApproximationSchemeConfiguration.h.
|
inherited |
Criteria messageApproximationScheme.
Definition at line 61 of file IApproximationSchemeConfiguration.h.
|
protectedinherited |
the type of the parameter estimator
Definition at line 761 of file genericBNLearner.h.
|
protectedinherited |
the set of rows' ranges within the database in which learning is done
Definition at line 824 of file genericBNLearner.h.
|
protectedinherited |
the score used
Definition at line 758 of file genericBNLearner.h.
|
protectedinherited |
the database to be used by the scores and parameter estimators
Definition at line 821 of file genericBNLearner.h.
|
protectedinherited |
the score selected for learning
Definition at line 755 of file genericBNLearner.h.
|
protectedinherited |
the selected learning algorithm
Definition at line 799 of file genericBNLearner.h.