![]() |
aGrUM
0.20.3
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 takeIntoAccountScore=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 | useNMLCorrection () |
indicate that we wish to use the NML correction for 3off2 and MIIC More... | |
void | useMDLCorrection () |
indicate that we wish to use the MDL correction for 3off2 and MIIC More... | |
void | useNoCorrection () |
indicate that we wish to use the NoCorr correction for 3off2 and MIIC 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 Attributes | |
ScoreType | scoreType_ {ScoreType::BDeu} |
the score selected for learning More... | |
Score * | score_ {nullptr} |
the score used More... | |
ParamEstimatorType | paramEstimatorType_ {ParamEstimatorType::ML} |
the type of the parameter estimator More... | |
double | epsilonEM_ {0.0} |
epsilon for EM. if espilon=0.0 : no EM More... | |
CorrectedMutualInformation * | mutualInfo_ {nullptr} |
the selected correction for 3off2 and miic More... | |
AprioriType | aprioriType_ {AprioriType::NO_APRIORI} |
the a priori selected for the score and parameters More... | |
Apriori * | apriori_ {nullptr} |
the apriori used More... | |
AprioriNoApriori * | noApriori_ {nullptr} |
double | aprioriWeight_ {1.0f} |
the weight of the apriori More... | |
StructuralConstraintSliceOrder | constraintSliceOrder_ |
the constraint for 2TBNs More... | |
StructuralConstraintIndegree | constraintIndegree_ |
the constraint for indegrees More... | |
StructuralConstraintTabuList | constraintTabuList_ |
the constraint for tabu lists More... | |
StructuralConstraintForbiddenArcs | constraintForbiddenArcs_ |
the constraint on forbidden arcs More... | |
StructuralConstraintPossibleEdges | constraintPossibleEdges_ |
the constraint on possible Edges More... | |
StructuralConstraintMandatoryArcs | constraintMandatoryArcs_ |
the constraint on forbidden arcs More... | |
AlgoType | selectedAlgo_ {AlgoType::GREEDY_HILL_CLIMBING} |
the selected learning algorithm More... | |
K2 | algoK2_ |
the K2 algorithm More... | |
Miic | algoMiic3off2_ |
the MIIC or 3off2 algorithm More... | |
CorrectedMutualInformation ::KModeTypes | kmode3Off2_ |
the penalty used in 3off2 More... | |
DAG2BNLearner | Dag2BN_ |
the parametric EM More... | |
GreedyHillClimbing | greedyHillClimbing_ |
the greedy hill climbing algorithm More... | |
LocalSearchWithTabuList | localSearchWithTabuList_ |
the local search with tabu list algorithm More... | |
Database | scoreDatabase_ |
the database to be used by the scores and parameter estimators More... | |
std::vector< std::pair< std::size_t, std::size_t > > | ranges_ |
the set of rows' ranges within the database in which learning is done More... | |
Database * | aprioriDatabase_ {nullptr} |
the database used by the Dirichlet a priori More... | |
std::string | aprioriDbname_ |
the filename for the Dirichlet a priori, if any More... | |
DAG | initialDag_ |
an initial DAG given to learners More... | |
const ApproximationScheme * | currentAlgorithm_ {nullptr} |
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 | prepareMiic3Off2_ () |
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
|
private |
read the first line of a file to find column names
|
inherited |
sets the apriori weight
Definition at line 397 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 310 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 320 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 330 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 |
Definition at line 369 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 357 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 273 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 283 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 293 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 382 of file genericBNLearner.cpp.
|
inherited |
checks whether the current score and apriori are compatible
Definition at line 816 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 885 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 896 of file genericBNLearner.cpp.
|
inherited |
reset the ranges to the one range corresponding to the whole database
Definition at line 491 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
protectedinherited |
create the apriori used for learning
Definition at line 428 of file genericBNLearner.cpp.
|
protectedinherited |
create the Corrected Mutual Information instance for Miic/3off2
Definition at line 622 of file genericBNLearner.cpp.
|
protectedinherited |
create the parameter estimator used for learning
Definition at line 530 of file genericBNLearner.cpp.
|
protectedinherited |
create the score used for learning
Definition at line 474 of file genericBNLearner.cpp.
|
inlinevirtualinherited |
get the current running time in second (double)
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1048 of file genericBNLearner.h.
|
inherited |
returns the database used by the BNLearner
Definition at line 494 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
returns the current database rows' ranges used for learning
Definition at line 486 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
returns the weight of the whole database
Definition at line 153 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
Disable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 913 of file genericBNLearner.h.
|
inlinevirtualinherited |
Disable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1003 of file genericBNLearner.h.
|
inlinevirtualinherited |
Disable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1056 of file genericBNLearner.h.
|
inlinevirtualinherited |
Disable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 959 of file genericBNLearner.h.
|
inlineinherited |
{@ /// distribute signals
Definition at line 875 of file genericBNLearner.h.
|
inlineinherited |
distribute signals
Definition at line 885 of file genericBNLearner.h.
learn a structure from a file (must have read the db before)
Definition at line 476 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 480 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 471 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
Enable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 921 of file genericBNLearner.h.
|
inlinevirtualinherited |
Enable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1010 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 1062 of file genericBNLearner.h.
|
inlinevirtualinherited |
Enable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 966 of file genericBNLearner.h.
|
inlinevirtualinherited |
Get the value of epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 905 of file genericBNLearner.h.
|
inherited |
Definition at line 315 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 325 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 336 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 352 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 363 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 278 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 288 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 299 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 907 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 915 of file genericBNLearner.cpp.
|
protectedinherited |
returns the type (as a string) of a given apriori
Definition at line 444 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 259 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 1132 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 128 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 930 of file genericBNLearner.h.
|
inlinevirtualinherited |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1018 of file genericBNLearner.h.
|
inlinevirtualinherited |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1070 of file genericBNLearner.h.
|
inlinevirtualinherited |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 974 of file genericBNLearner.h.
|
inherited |
get the list of arcs hiding latent variables
OperationNotAllowed | when 3off2 or MIIC is not the selected algorithm |
Definition at line 227 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 614 of file genericBNLearner.cpp.
|
protectedinherited |
returns the DAG learnt
Definition at line 649 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 596 of file genericBNLearner.cpp.
BayesNet< GUM_SCALAR > gum::learning::BNLearner< GUM_SCALAR >::learnParameters | ( | const DAG & | dag, |
bool | takeIntoAccountScore = true |
||
) |
learns a BN (its parameters) when its structure is known
dag | the structure of the Bayesian network |
takeIntoAccountScore | 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 926 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 944 of file genericBNLearner.cpp.
|
inlinevirtualinherited |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 995 of file genericBNLearner.h.
|
inlinevirtualinherited |
returns the timeout (in seconds)
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1040 of file genericBNLearner.h.
|
inherited |
Returns the approximation scheme message.
Definition at line 38 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 951 of file genericBNLearner.h.
|
inherited |
returns the variable name corresponding to a given node id
Definition at line 133 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
returns the names of the variables in the database
Definition at line 466 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
Definition at line 498 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
OperationNotAllowed | if scheme not performed |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1124 of file genericBNLearner.h.
|
inherited |
Definition at line 500 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 1088 of file genericBNLearner.h.
|
protectedinherited |
prepares the initial graph for 3off2 or miic
Definition at line 566 of file genericBNLearner.cpp.
|
inherited |
Return the pseudoconts ofNodeIds vars in the base in a raw array.
vars | a vector of |
Definition at line 959 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 968 of file genericBNLearner.cpp.
|
staticprotectedinherited |
reads a file and returns a databaseVectInRam
Definition at line 402 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 148 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlineinherited |
{@ /// distribute signals
Definition at line 871 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 138 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 897 of file genericBNLearner.h.
|
inherited |
assign a set of forbidden arcs
Definition at line 305 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
sets an initial DAG structure
Definition at line 156 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
assign a set of forbidden arcs
Definition at line 342 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
sets the max indegree
Definition at line 195 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 987 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 1032 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 943 of file genericBNLearner.h.
|
inlinevirtualinherited |
how many samples between 2 stopping isEnableds
OutOfLowerBound | if p<1 |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1081 of file genericBNLearner.h.
|
inherited |
assign a set of forbidden edges
Definition at line 264 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
assign a set of forbidden edges
Definition at line 268 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 143 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 379 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 384 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
verbosity
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1098 of file genericBNLearner.h.
|
inlinevirtualinherited |
history
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1116 of file genericBNLearner.h.
|
inherited |
indicate that we wish to use 3off2
Definition at line 200 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 433 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
use the Dirichlet apriori
Definition at line 421 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 411 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 846 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 97 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 256 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 244 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
indicate that we wish to use K2
Definition at line 232 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use K2
Definition at line 238 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 249 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use the MDL correction for 3off2 and MIIC
indicate that we wish to use the MDL correction for 3off2
OperationNotAllowed | when 3off2 is not the selected algorithm |
Definition at line 217 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use MIIC
Definition at line 206 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use the NML correction for 3off2 and MIIC
indicate that we wish to use the NML correction for 3off2
OperationNotAllowed | when 3off2 is not the selected algorithm |
Definition at line 212 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
use no apriori
Definition at line 405 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use the NoCorr correction for 3off2 and MIIC
indicate that we wish to use the NoCorr correction for 3off2
OperationNotAllowed | when 3off2 is not the selected algorithm |
Definition at line 222 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use an AIC score
Definition at line 159 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use a BD score
Definition at line 165 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use a BDeu score
Definition at line 171 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use a BIC score
Definition at line 177 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use a K2 score
Definition at line 183 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inherited |
indicate that we wish to use a Log2Likelihood score
Definition at line 189 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::Database().
|
inlinevirtualinherited |
verbosity
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1105 of file genericBNLearner.h.
|
protectedinherited |
the K2 algorithm
Definition at line 795 of file genericBNLearner.h.
|
protectedinherited |
the MIIC or 3off2 algorithm
Definition at line 798 of file genericBNLearner.h.
|
protectedinherited |
the apriori used
Definition at line 766 of file genericBNLearner.h.
|
protectedinherited |
the database used by the Dirichlet a priori
Definition at line 820 of file genericBNLearner.h.
|
protectedinherited |
the filename for the Dirichlet a priori, if any
Definition at line 823 of file genericBNLearner.h.
|
protectedinherited |
the a priori selected for the score and parameters
Definition at line 763 of file genericBNLearner.h.
|
protectedinherited |
the weight of the apriori
Definition at line 771 of file genericBNLearner.h.
|
protectedinherited |
the constraint on forbidden arcs
Definition at line 783 of file genericBNLearner.h.
|
protectedinherited |
the constraint for indegrees
Definition at line 777 of file genericBNLearner.h.
|
protectedinherited |
the constraint on forbidden arcs
Definition at line 789 of file genericBNLearner.h.
|
protectedinherited |
the constraint on possible Edges
Definition at line 786 of file genericBNLearner.h.
|
protectedinherited |
the constraint for 2TBNs
Definition at line 774 of file genericBNLearner.h.
|
protectedinherited |
the constraint for tabu lists
Definition at line 780 of file genericBNLearner.h.
|
protectedinherited |
Definition at line 829 of file genericBNLearner.h.
|
protectedinherited |
the parametric EM
Definition at line 805 of file genericBNLearner.h.
|
protectedinherited |
epsilon for EM. if espilon=0.0 : no EM
Definition at line 757 of file genericBNLearner.h.
|
protectedinherited |
the greedy hill climbing algorithm
Definition at line 808 of file genericBNLearner.h.
|
protectedinherited |
an initial DAG given to learners
Definition at line 826 of file genericBNLearner.h.
|
protectedinherited |
the penalty used in 3off2
Definition at line 801 of file genericBNLearner.h.
|
protectedinherited |
the local search with tabu list algorithm
Definition at line 811 of file genericBNLearner.h.
|
protectedinherited |
the selected correction for 3off2 and miic
Definition at line 760 of file genericBNLearner.h.
|
protectedinherited |
Definition at line 768 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 754 of file genericBNLearner.h.
|
protectedinherited |
the set of rows' ranges within the database in which learning is done
Definition at line 817 of file genericBNLearner.h.
|
protectedinherited |
the score used
Definition at line 751 of file genericBNLearner.h.
|
protectedinherited |
the database to be used by the scores and parameter estimators
Definition at line 814 of file genericBNLearner.h.
|
protectedinherited |
the score selected for learning
Definition at line 748 of file genericBNLearner.h.
|
protectedinherited |
the selected learning algorithm
Definition at line 792 of file genericBNLearner.h.