![]() |
aGrUM
0.16.0
|
A pack of learning algorithms that can easily be used. More...
#include <genericBNLearner.h>
Public Attributes | |
Signaler3< Size, double, double > | onProgress |
Progression, error and time. More... | |
Signaler1< std::string > | onStop |
Criteria messageApproximationScheme. More... | |
Public Member Functions | |
void | __setAprioriWeight (double weight) |
sets the apriori weight More... | |
void | setMandatoryArcs (const ArcSet &set) |
assign a set of forbidden arcs More... | |
Constructors / Destructors | |
genericBNLearner (const std::string &filename, const std::vector< std::string > &missing_symbols) | |
default constructor More... | |
genericBNLearner (const DatabaseTable<> &db) | |
default constructor More... | |
template<typename GUM_SCALAR > | |
genericBNLearner (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... | |
genericBNLearner (const genericBNLearner &) | |
copy constructor More... | |
genericBNLearner (genericBNLearner &&) | |
move constructor More... | |
virtual | ~genericBNLearner () |
destructor More... | |
Operators | |
genericBNLearner & | operator= (const genericBNLearner &) |
copy operator More... | |
genericBNLearner & | operator= (genericBNLearner &&) |
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... | |
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... | |
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... | |
Classes | |
class | Database |
a helper to easily read databases More... | |
A pack of learning algorithms that can easily be used.
The pack currently contains K2, GreedyHillClimbing and LocalSearchWithTabuList also 3off2/miic
Definition at line 107 of file genericBNLearner.h.
|
strong |
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 126 of file genericBNLearner.h.
|
stronginherited |
The different state of an approximation scheme.
Enumerator | |
---|---|
Undefined | |
Continue | |
Epsilon | |
Rate | |
Limit | |
TimeLimit | |
Stopped |
Definition at line 65 of file IApproximationSchemeConfiguration.h.
|
strong |
an enumeration to select the apriori
Enumerator | |
---|---|
NO_APRIORI | |
SMOOTHING | |
DIRICHLET_FROM_DATABASE | |
BDEU |
Definition at line 118 of file genericBNLearner.h.
an enumeration to select the type of parameter estimation we shall apply
Enumerator | |
---|---|
ML |
Definition at line 115 of file genericBNLearner.h.
|
strong |
an enumeration enabling to select easily the score we wish to use
Enumerator | |
---|---|
AIC | |
BD | |
BDeu | |
BIC | |
K2 | |
LOG2LIKELIHOOD |
Definition at line 111 of file genericBNLearner.h.
gum::learning::genericBNLearner::genericBNLearner | ( | 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
Definition at line 191 of file genericBNLearner.cpp.
References __no_apriori, __score_database, and gum::learning::genericBNLearner::Database::databaseTable().
gum::learning::genericBNLearner::genericBNLearner | ( | const DatabaseTable<> & | db | ) |
default constructor
read the database file for the score / parameter estimation and var names
Definition at line 202 of file genericBNLearner.cpp.
References __no_apriori, __score_database, and gum::learning::genericBNLearner::Database::databaseTable().
gum::learning::genericBNLearner::genericBNLearner | ( | 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
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. For instance, 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. |
parse_database | if true, the modalities specified by the user will be considered as a superset of the modalities of the variables. 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). |
Definition at line 89 of file genericBNLearner_tpl.h.
References __no_apriori, __score_database, and gum::learning::genericBNLearner::Database::databaseTable().
gum::learning::genericBNLearner::genericBNLearner | ( | const genericBNLearner & | from | ) |
copy constructor
Definition at line 211 of file genericBNLearner.cpp.
References __no_apriori, __score_database, and gum::learning::genericBNLearner::Database::databaseTable().
gum::learning::genericBNLearner::genericBNLearner | ( | genericBNLearner && | from | ) |
move constructor
Definition at line 234 of file genericBNLearner.cpp.
References __no_apriori, __score_database, and gum::learning::genericBNLearner::Database::databaseTable().
|
virtual |
destructor
Definition at line 260 of file genericBNLearner.cpp.
References __apriori, __apriori_database, __mutual_info, __no_apriori, and __score.
|
staticprotected |
checks whether the extension of a CSV filename is correct
Definition at line 411 of file genericBNLearner.cpp.
References GUM_ERROR.
Referenced by __readFile(), and gum::learning::genericBNLearner::Database::Database().
|
protected |
create the apriori used for learning
Definition at line 460 of file genericBNLearner.cpp.
References __apriori, __apriori_database, __apriori_dbname, __apriori_type, __apriori_weight, __score_database, BDEU, gum::learning::genericBNLearner::Database::databaseTable(), DIRICHLET_FROM_DATABASE, GUM_ERROR, gum::learning::genericBNLearner::Database::missingSymbols(), NO_APRIORI, gum::learning::genericBNLearner::Database::nodeId2Columns(), gum::learning::genericBNLearner::Database::parser(), gum::learning::Apriori< ALLOC >::setWeight(), and SMOOTHING.
Referenced by chi2(), G2(), learnDAG(), and logLikelihood().
|
protected |
create the Corrected Mutual Information instance for Miic/3off2
Definition at line 661 of file genericBNLearner.cpp.
References __3off2_kmode, __mutual_info, __no_apriori, __ranges, __score_database, GUM_ERROR, gum::learning::genericBNLearner::Database::nodeId2Columns(), gum::learning::genericBNLearner::Database::parser(), gum::learning::CorrectedMutualInformation< ALLOC >::useMDL(), gum::learning::CorrectedMutualInformation< ALLOC >::useNML(), and gum::learning::CorrectedMutualInformation< ALLOC >::useNoCorr().
Referenced by __prepare_miic_3off2().
|
protected |
create the parameter estimator used for learning
Definition at line 567 of file genericBNLearner.cpp.
References __apriori, __no_apriori, __param_estimator_type, __ranges, __score, __score_database, GUM_ERROR, gum::learning::Score< ALLOC >::internalApriori(), ML, gum::learning::genericBNLearner::Database::nodeId2Columns(), and gum::learning::ParamEstimator< ALLOC >::setRanges().
|
protected |
create the score used for learning
Definition at line 509 of file genericBNLearner.cpp.
References __apriori, __ranges, __score, __score_database, __score_type, AIC, BD, BDeu, BIC, GUM_ERROR, K2, LOG2LIKELIHOOD, gum::learning::genericBNLearner::Database::nodeId2Columns(), and gum::learning::genericBNLearner::Database::parser().
Referenced by learnDAG().
|
protected |
returns the type (as a string) of a given apriori
Definition at line 507 of file genericBNLearner_inl.h.
References __apriori_type, BDEU, DIRICHLET_FROM_DATABASE, GUM_ERROR, NO_APRIORI, and SMOOTHING.
Referenced by checkScoreAprioriCompatibility().
|
protected |
returns the DAG learnt
Definition at line 689 of file genericBNLearner.cpp.
References __apriori_database, __apriori_type, __constraint_ForbiddenArcs, __constraint_Indegree, __constraint_MandatoryArcs, __constraint_PossibleEdges, __constraint_SliceOrder, __constraint_TabuList, __greedy_hill_climbing, __initial_dag, __K2, __local_search_with_tabu_list, __miic_3off2, __mutual_info, __prepare_miic_3off2(), __score, __score_database, __selected_algo, gum::DAG::addArc(), gum::NodeGraphPart::addNodeWithId(), gum::learning::K2::approximationScheme(), gum::learning::StructuralConstraintForbiddenArcs::arcs(), gum::learning::StructuralConstraintMandatoryArcs::arcs(), gum::learning::genericBNLearner::Database::databaseTable(), DIRICHLET_FROM_DATABASE, gum::ArcGraphPart::eraseArc(), gum::NodeGraphPart::exists(), GREEDY_HILL_CLIMBING, GUM_ERROR, gum::learning::IDatabaseTable< T_DATA, ALLOC >::hasMissingValues(), K2, gum::learning::K2::learnStructure(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), gum::learning::Miic::learnStructure(), LOCAL_SEARCH_WITH_TABU_LIST, MIIC_THREE_OFF_TWO, gum::learning::K2::order(), and gum::SequenceImplementation< Key, Alloc, Gen >::pos().
Referenced by learnDAG().
|
protected |
prepares the initial graph for 3off2 or miic
Definition at line 605 of file genericBNLearner.cpp.
References __constraint_ForbiddenArcs, __constraint_MandatoryArcs, __createCorrectedMutualInformation(), __miic_3off2, __score_database, gum::learning::Miic::addConstraints(), gum::UndiGraph::addEdge(), gum::NodeGraphPart::addNodeWithId(), gum::learning::StructuralConstraintMandatoryArcs::arcs(), gum::learning::StructuralConstraintForbiddenArcs::arcs(), gum::learning::genericBNLearner::Database::databaseTable(), gum::HashTable< Key, Val, Alloc >::insert(), and gum::learning::IDatabaseTable< T_DATA, ALLOC >::nbVariables().
Referenced by __learnDAG(), and learnMixedStructure().
|
staticprotected |
reads a file and returns a databaseVectInRam
Definition at line 433 of file genericBNLearner.cpp.
References __checkFileName(), database(), gum::learning::IDBInitializer< ALLOC >::fillDatabase(), gum::learning::DBTranslatorSet< ALLOC >::insertTranslator(), gum::learning::DatabaseTable< ALLOC >::reorder(), gum::learning::DatabaseTable< ALLOC >::setVariableNames(), and gum::learning::IDBInitializer< ALLOC >::variableNames().
INLINE void gum::learning::genericBNLearner::__setAprioriWeight | ( | double | weight | ) |
sets the apriori weight
Definition at line 451 of file genericBNLearner_inl.h.
References __apriori_weight, checkScoreAprioriCompatibility(), GUM_ERROR, and gum::learning::genericBNLearner::Database::weight().
Referenced by useAprioriBDeu(), useAprioriDirichlet(), and useAprioriSmoothing().
INLINE void gum::learning::genericBNLearner::addForbiddenArc | ( | const Arc & | arc | ) |
Definition at line 359 of file genericBNLearner_inl.h.
References __constraint_ForbiddenArcs, and gum::learning::StructuralConstraintForbiddenArcs::addArc().
Referenced by addForbiddenArc().
INLINE void gum::learning::genericBNLearner::addForbiddenArc | ( | const NodeId | tail, |
const NodeId | head | ||
) |
Definition at line 369 of file genericBNLearner_inl.h.
References addForbiddenArc().
INLINE void gum::learning::genericBNLearner::addForbiddenArc | ( | const std::string & | tail, |
const std::string & | head | ||
) |
Definition at line 381 of file genericBNLearner_inl.h.
References addForbiddenArc(), and gum::learning::genericBNLearner::Database::idFromName().
INLINE void gum::learning::genericBNLearner::addMandatoryArc | ( | const Arc & | arc | ) |
Definition at line 398 of file genericBNLearner_inl.h.
References __constraint_MandatoryArcs, and gum::learning::StructuralConstraintMandatoryArcs::addArc().
Referenced by addMandatoryArc().
INLINE void gum::learning::genericBNLearner::addMandatoryArc | ( | const NodeId | tail, |
const NodeId | head | ||
) |
Definition at line 420 of file genericBNLearner_inl.h.
References addMandatoryArc().
INLINE void gum::learning::genericBNLearner::addMandatoryArc | ( | const std::string & | tail, |
const std::string & | head | ||
) |
Definition at line 408 of file genericBNLearner_inl.h.
References addMandatoryArc(), and gum::learning::genericBNLearner::Database::idFromName().
INLINE void gum::learning::genericBNLearner::addPossibleEdge | ( | const Edge & | edge | ) |
Definition at line 320 of file genericBNLearner_inl.h.
References __constraint_PossibleEdges, and gum::learning::StructuralConstraintPossibleEdges::addEdge().
Referenced by addPossibleEdge().
INLINE void gum::learning::genericBNLearner::addPossibleEdge | ( | const NodeId | tail, |
const NodeId | head | ||
) |
Definition at line 330 of file genericBNLearner_inl.h.
References addPossibleEdge().
INLINE void gum::learning::genericBNLearner::addPossibleEdge | ( | const std::string & | tail, |
const std::string & | head | ||
) |
Definition at line 342 of file genericBNLearner_inl.h.
References addPossibleEdge(), and gum::learning::genericBNLearner::Database::idFromName().
std::string gum::learning::genericBNLearner::checkScoreAprioriCompatibility | ( | ) |
checks whether the current score and apriori are compatible
Definition at line 866 of file genericBNLearner.cpp.
References __apriori_weight, __getAprioriType(), __score_type, AIC, BD, BDeu, BIC, gum::learning::ScoreAIC< ALLOC >::isAprioriCompatible(), gum::learning::ScoreBIC< ALLOC >::isAprioriCompatible(), gum::learning::ScoreLog2Likelihood< ALLOC >::isAprioriCompatible(), gum::learning::ScoreBDeu< ALLOC >::isAprioriCompatible(), gum::learning::ScoreK2< ALLOC >::isAprioriCompatible(), gum::learning::ScoreBD< ALLOC >::isAprioriCompatible(), K2, and LOG2LIKELIHOOD.
Referenced by __setAprioriWeight(), useAprioriBDeu(), useAprioriDirichlet(), useAprioriSmoothing(), useNoApriori(), useScoreAIC(), useScoreBD(), useScoreBDeu(), useScoreBIC(), useScoreK2(), and useScoreLog2Likelihood().
std::pair< double, double > gum::learning::genericBNLearner::chi2 | ( | const NodeId | id1, |
const NodeId | id2, | ||
const std::vector< NodeId > & | knowing = {} |
||
) |
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 941 of file genericBNLearner.cpp.
References __apriori, __createApriori(), __score_database, databaseRanges(), gum::learning::genericBNLearner::Database::parser(), and gum::learning::IndepTestChi2< ALLOC >::statistics().
Referenced by chi2().
std::pair< double, double > gum::learning::genericBNLearner::chi2 | ( | const std::string & | name1, |
const std::string & | name2, | ||
const std::vector< std::string > & | knowing = {} |
||
) |
Return the <statistic,pvalue> pair for the BNLearner.
id1 | first variable |
id2 | second variable |
knowing | list of observed variables |
Definition at line 951 of file genericBNLearner.cpp.
References chi2(), and idFromName().
INLINE void gum::learning::genericBNLearner::clearDatabaseRanges | ( | ) |
reset the ranges to the one range corresponding to the whole database
Definition at line 543 of file genericBNLearner_inl.h.
References __ranges.
|
inlinevirtual |
get the current running time in second (double)
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1035 of file genericBNLearner.h.
References __current_algorithm, gum::ApproximationScheme::currentTime(), and GUM_ERROR.
INLINE const DatabaseTable & gum::learning::genericBNLearner::database | ( | ) | const |
returns the database used by the BNLearner
Definition at line 546 of file genericBNLearner_inl.h.
References __score_database, and gum::learning::genericBNLearner::Database::databaseTable().
Referenced by __readFile(), and gum::learning::readFile().
INLINE const std::vector< std::pair< std::size_t, std::size_t > > & gum::learning::genericBNLearner::databaseRanges | ( | ) | const |
returns the current database rows' ranges used for learning
Definition at line 538 of file genericBNLearner_inl.h.
References __ranges.
Referenced by chi2(), G2(), and logLikelihood().
INLINE double gum::learning::genericBNLearner::databaseWeight | ( | ) | const |
returns the weight of the whole database
Definition at line 173 of file genericBNLearner_inl.h.
References __score_database, and gum::learning::genericBNLearner::Database::weight().
|
inlinevirtual |
Disable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 900 of file genericBNLearner.h.
References gum::learning::K2::approximationScheme(), and gum::ApproximationScheme::disableEpsilon().
|
inlinevirtual |
Disable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 990 of file genericBNLearner.h.
References gum::learning::K2::approximationScheme(), and gum::ApproximationScheme::disableMaxIter().
|
inlinevirtual |
Disable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1043 of file genericBNLearner.h.
References gum::learning::K2::approximationScheme(), and gum::ApproximationScheme::disableMaxTime().
|
inlinevirtual |
Disable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 946 of file genericBNLearner.h.
References gum::learning::K2::approximationScheme(), and gum::ApproximationScheme::disableMinEpsilonRate().
|
inline |
{@ /// distribute signals
Definition at line 862 of file genericBNLearner.h.
References GUM_EMIT3, gum::IApproximationSchemeConfiguration::onProgress, and setCurrentApproximationScheme().
Referenced by gum::learning::BNLearnerListener::whenProgress().
|
inline |
distribute signals
Definition at line 872 of file genericBNLearner.h.
References GUM_EMIT1, gum::IApproximationSchemeConfiguration::onStop, and setCurrentApproximationScheme().
Referenced by gum::learning::BNLearnerListener::whenStop().
INLINE const std::vector< std::size_t > & gum::learning::genericBNLearner::domainSizes | ( | ) | const |
returns the domain sizes of the variables in the database
Definition at line 532 of file genericBNLearner_inl.h.
References __score_database, and gum::learning::genericBNLearner::Database::domainSizes().
|
inlinevirtual |
Enable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 908 of file genericBNLearner.h.
References gum::learning::K2::approximationScheme(), and gum::ApproximationScheme::enableEpsilon().
|
inlinevirtual |
Enable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 997 of file genericBNLearner.h.
References gum::learning::K2::approximationScheme(), and gum::ApproximationScheme::enableMaxIter().
|
inlinevirtual |
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 1049 of file genericBNLearner.h.
References gum::learning::K2::approximationScheme(), and gum::ApproximationScheme::enableMaxTime().
|
inlinevirtual |
Enable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 953 of file genericBNLearner.h.
References gum::learning::K2::approximationScheme(), and gum::ApproximationScheme::enableMinEpsilonRate().
|
inlinevirtual |
Get the value of epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 892 of file genericBNLearner.h.
References __current_algorithm, gum::ApproximationScheme::epsilon(), and GUM_ERROR.
Referenced by useEM().
INLINE void gum::learning::genericBNLearner::eraseForbiddenArc | ( | const Arc & | arc | ) |
Definition at line 364 of file genericBNLearner_inl.h.
References __constraint_ForbiddenArcs, and gum::learning::StructuralConstraintForbiddenArcs::eraseArc().
Referenced by eraseForbiddenArc().
INLINE void gum::learning::genericBNLearner::eraseForbiddenArc | ( | const NodeId | tail, |
const NodeId | head | ||
) |
Definition at line 375 of file genericBNLearner_inl.h.
References eraseForbiddenArc().
INLINE void gum::learning::genericBNLearner::eraseForbiddenArc | ( | const std::string & | tail, |
const std::string & | head | ||
) |
Definition at line 387 of file genericBNLearner_inl.h.
References eraseForbiddenArc(), and gum::learning::genericBNLearner::Database::idFromName().
INLINE void gum::learning::genericBNLearner::eraseMandatoryArc | ( | const Arc & | arc | ) |
Definition at line 403 of file genericBNLearner_inl.h.
References __constraint_MandatoryArcs, and gum::learning::StructuralConstraintMandatoryArcs::eraseArc().
Referenced by eraseMandatoryArc().
INLINE void gum::learning::genericBNLearner::eraseMandatoryArc | ( | const NodeId | tail, |
const NodeId | head | ||
) |
Definition at line 426 of file genericBNLearner_inl.h.
References eraseMandatoryArc().
INLINE void gum::learning::genericBNLearner::eraseMandatoryArc | ( | const std::string & | tail, |
const std::string & | head | ||
) |
Definition at line 414 of file genericBNLearner_inl.h.
References eraseMandatoryArc(), and gum::learning::genericBNLearner::Database::idFromName().
INLINE void gum::learning::genericBNLearner::erasePossibleEdge | ( | const Edge & | edge | ) |
Definition at line 325 of file genericBNLearner_inl.h.
References __constraint_PossibleEdges, and gum::learning::StructuralConstraintPossibleEdges::eraseEdge().
Referenced by erasePossibleEdge().
INLINE void gum::learning::genericBNLearner::erasePossibleEdge | ( | const NodeId | tail, |
const NodeId | head | ||
) |
Definition at line 336 of file genericBNLearner_inl.h.
References erasePossibleEdge().
INLINE void gum::learning::genericBNLearner::erasePossibleEdge | ( | const std::string & | tail, |
const std::string & | head | ||
) |
Definition at line 348 of file genericBNLearner_inl.h.
References erasePossibleEdge(), and gum::learning::genericBNLearner::Database::idFromName().
std::pair< double, double > gum::learning::genericBNLearner::G2 | ( | const NodeId | id1, |
const NodeId | id2, | ||
const std::vector< NodeId > & | knowing = {} |
||
) |
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 963 of file genericBNLearner.cpp.
References __apriori, __createApriori(), __score_database, databaseRanges(), gum::learning::genericBNLearner::Database::parser(), and gum::learning::IndepTestG2< ALLOC >::statistics().
Referenced by G2().
std::pair< double, double > gum::learning::genericBNLearner::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.
id1 | first variable |
id2 | second variable |
knowing | list of observed variables |
Definition at line 972 of file genericBNLearner.cpp.
References G2(), and idFromName().
INLINE bool gum::learning::genericBNLearner::hasMissingValues | ( | ) | const |
returns true if the learner's database has missing values
Definition at line 306 of file genericBNLearner_inl.h.
References __score_database, gum::learning::genericBNLearner::Database::databaseTable(), and gum::learning::IDatabaseTable< T_DATA, ALLOC >::hasMissingValues().
|
inlinevirtual |
OperationNotAllowed | if scheme not performed or verbosity=false |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1119 of file genericBNLearner.h.
References __current_algorithm, GUM_ERROR, and gum::ApproximationScheme::history().
INLINE NodeId gum::learning::genericBNLearner::idFromName | ( | const std::string & | var_name | ) | const |
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 147 of file genericBNLearner_inl.h.
References __score_database, and gum::learning::genericBNLearner::Database::idFromName().
Referenced by chi2(), G2(), and logLikelihood().
|
inlinevirtual |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 917 of file genericBNLearner.h.
References __current_algorithm, GUM_ERROR, and gum::ApproximationScheme::isEnabledEpsilon().
|
inlinevirtual |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1005 of file genericBNLearner.h.
References __current_algorithm, GUM_ERROR, and gum::ApproximationScheme::isEnabledMaxIter().
|
inlinevirtual |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1057 of file genericBNLearner.h.
References __current_algorithm, GUM_ERROR, and gum::ApproximationScheme::isEnabledMaxTime().
|
inlinevirtual |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 961 of file genericBNLearner.h.
References __current_algorithm, GUM_ERROR, and gum::ApproximationScheme::isEnabledMinEpsilonRate().
INLINE const std::vector< Arc > gum::learning::genericBNLearner::latentVariables | ( | ) | const |
get the list of arcs hiding latent variables
OperationNotAllowed | when 3off2 is not the selected algorithm |
Definition at line 266 of file genericBNLearner_inl.h.
References __miic_3off2, __selected_algo, GUM_ERROR, gum::learning::Miic::latentVariables(), and MIIC_THREE_OFF_TWO.
DAG gum::learning::genericBNLearner::learnDAG | ( | ) |
learn a structure from a file (must have read the db before)
Definition at line 653 of file genericBNLearner.cpp.
References __createApriori(), __createScore(), and __learnDAG().
MixedGraph gum::learning::genericBNLearner::learnMixedStructure | ( | ) |
learn a partial structure from a file (must have read the db before and must have selected miic or 3off2)
Definition at line 635 of file genericBNLearner.cpp.
References __miic_3off2, __mutual_info, __prepare_miic_3off2(), __score_database, __selected_algo, gum::learning::genericBNLearner::Database::databaseTable(), GUM_ERROR, gum::learning::IDatabaseTable< T_DATA, ALLOC >::hasMissingValues(), gum::learning::Miic::learnMixedStructure(), and MIIC_THREE_OFF_TWO.
double gum::learning::genericBNLearner::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.
vars | a vector of NodeIds |
knowing | an optional vector of conditioning NodeIds |
Definition at line 984 of file genericBNLearner.cpp.
References __apriori, __createApriori(), __score_database, databaseRanges(), gum::learning::genericBNLearner::Database::parser(), and gum::learning::ScoreLog2Likelihood< ALLOC >::score().
Referenced by logLikelihood().
double gum::learning::genericBNLearner::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.
vars | a vector of name of rows |
knowing | an optional vector of conditioning rows |
Definition at line 1002 of file genericBNLearner.cpp.
References idFromName(), and logLikelihood().
|
inlinevirtual |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 982 of file genericBNLearner.h.
References __current_algorithm, GUM_ERROR, and gum::ApproximationScheme::maxIter().
|
inlinevirtual |
returns the timeout (in seconds)
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1027 of file genericBNLearner.h.
References __current_algorithm, GUM_ERROR, and gum::ApproximationScheme::maxTime().
|
inherited |
Returns the approximation scheme message.
Definition at line 40 of file IApproximationSchemeConfiguration_inl.h.
References gum::IApproximationSchemeConfiguration::Continue, gum::IApproximationSchemeConfiguration::Epsilon, gum::IApproximationSchemeConfiguration::epsilon(), gum::IApproximationSchemeConfiguration::Limit, gum::IApproximationSchemeConfiguration::maxIter(), gum::IApproximationSchemeConfiguration::maxTime(), gum::IApproximationSchemeConfiguration::minEpsilonRate(), gum::IApproximationSchemeConfiguration::Rate, gum::IApproximationSchemeConfiguration::stateApproximationScheme(), gum::IApproximationSchemeConfiguration::Stopped, gum::IApproximationSchemeConfiguration::TimeLimit, and gum::IApproximationSchemeConfiguration::Undefined.
Referenced by gum::ApproximationScheme::_stopScheme(), gum::ApproximationScheme::continueApproximationScheme(), and gum::credal::InferenceEngine< GUM_SCALAR >::getApproximationSchemeMsg().
|
inlinevirtual |
Get the value of the minimal epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 938 of file genericBNLearner.h.
References __current_algorithm, GUM_ERROR, and gum::ApproximationScheme::minEpsilonRate().
INLINE const std::string & gum::learning::genericBNLearner::nameFromId | ( | NodeId | id | ) | const |
returns the variable name corresponding to a given node id
Definition at line 152 of file genericBNLearner_inl.h.
References __score_database, and gum::learning::genericBNLearner::Database::nameFromId().
INLINE const std::vector< std::string > & gum::learning::genericBNLearner::names | ( | ) | const |
returns the names of the variables in the database
Definition at line 526 of file genericBNLearner_inl.h.
References __score_database, and gum::learning::genericBNLearner::Database::names().
INLINE Size gum::learning::genericBNLearner::nbCols | ( | ) | const |
Definition at line 550 of file genericBNLearner_inl.h.
References __score_database, and gum::learning::genericBNLearner::Database::domainSizes().
|
inlinevirtual |
OperationNotAllowed | if scheme not performed |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1111 of file genericBNLearner.h.
References __current_algorithm, GUM_ERROR, and gum::ApproximationScheme::nbrIterations().
INLINE Size gum::learning::genericBNLearner::nbRows | ( | ) | const |
Definition at line 554 of file genericBNLearner_inl.h.
References __score_database, gum::learning::genericBNLearner::Database::databaseTable(), and gum::learning::IDatabaseTable< T_DATA, ALLOC >::size().
genericBNLearner & gum::learning::genericBNLearner::operator= | ( | const genericBNLearner & | from | ) |
copy operator
Definition at line 274 of file genericBNLearner.cpp.
References __3off2_kmode, __apriori, __apriori_database, __apriori_dbname, __apriori_type, __apriori_weight, __constraint_ForbiddenArcs, __constraint_Indegree, __constraint_MandatoryArcs, __constraint_SliceOrder, __constraint_TabuList, __current_algorithm, __EMepsilon, __greedy_hill_climbing, __initial_dag, __K2, __local_search_with_tabu_list, __miic_3off2, __mutual_info, __param_estimator_type, __ranges, __score, __score_database, __score_type, and __selected_algo.
genericBNLearner & gum::learning::genericBNLearner::operator= | ( | genericBNLearner && | from | ) |
move operator
Definition at line 322 of file genericBNLearner.cpp.
References __3off2_kmode, __apriori, __apriori_database, __apriori_dbname, __apriori_type, __apriori_weight, __constraint_ForbiddenArcs, __constraint_Indegree, __constraint_MandatoryArcs, __constraint_SliceOrder, __constraint_TabuList, __current_algorithm, __EMepsilon, __greedy_hill_climbing, __initial_dag, __K2, __local_search_with_tabu_list, __miic_3off2, __mutual_info, __param_estimator_type, __ranges, __score, __score_database, __score_type, and __selected_algo.
|
inlinevirtual |
how many samples between 2 stopping isEnableds
OutOfLowerBound | if p<1 |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1075 of file genericBNLearner.h.
References __current_algorithm, GUM_ERROR, and gum::ApproximationScheme::periodSize().
INLINE double gum::learning::genericBNLearner::recordWeight | ( | const std::size_t | i | ) | const |
returns the weight of the ith record
OutOfBounds | if i is outside the set of indices of the records |
Definition at line 168 of file genericBNLearner_inl.h.
References __score_database, and gum::learning::genericBNLearner::Database::weight().
|
inline |
{@ /// distribute signals
Definition at line 856 of file genericBNLearner.h.
References __current_algorithm.
Referenced by gum::learning::BNLearnerListener::BNLearnerListener(), distributeProgress(), and distributeStop().
INLINE void gum::learning::genericBNLearner::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
assign new weight to the rows of the learning database
Definition at line 157 of file genericBNLearner_inl.h.
References __score_database, and gum::learning::genericBNLearner::Database::setDatabaseWeight().
|
inlinevirtual |
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 884 of file genericBNLearner.h.
References gum::learning::K2::approximationScheme(), and gum::ApproximationScheme::setEpsilon().
INLINE void gum::learning::genericBNLearner::setForbiddenArcs | ( | const ArcSet & | set | ) |
assign a set of forbidden arcs
Definition at line 354 of file genericBNLearner_inl.h.
References __constraint_ForbiddenArcs, and gum::learning::StructuralConstraintForbiddenArcs::setArcs().
INLINE void gum::learning::genericBNLearner::setInitialDAG | ( | const DAG & | dag | ) |
sets an initial DAG structure
Definition at line 178 of file genericBNLearner_inl.h.
References __initial_dag.
INLINE void gum::learning::genericBNLearner::setMandatoryArcs | ( | const ArcSet & | set | ) |
assign a set of forbidden arcs
Definition at line 393 of file genericBNLearner_inl.h.
References __constraint_MandatoryArcs, and gum::learning::StructuralConstraintMandatoryArcs::setArcs().
INLINE void gum::learning::genericBNLearner::setMaxIndegree | ( | Size | max_indegree | ) |
sets the max indegree
Definition at line 219 of file genericBNLearner_inl.h.
References __constraint_Indegree, and gum::learning::StructuralConstraintIndegree::setMaxIndegree().
|
inlinevirtual |
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 974 of file genericBNLearner.h.
References gum::learning::K2::approximationScheme(), and gum::ApproximationScheme::setMaxIter().
|
inlinevirtual |
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 1019 of file genericBNLearner.h.
References gum::learning::K2::approximationScheme(), and gum::ApproximationScheme::setMaxTime().
|
inlinevirtual |
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 930 of file genericBNLearner.h.
References gum::learning::K2::approximationScheme(), and gum::ApproximationScheme::setMinEpsilonRate().
|
inlinevirtual |
how many samples between 2 stopping isEnableds
OutOfLowerBound | if p<1 |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1068 of file genericBNLearner.h.
References gum::learning::K2::approximationScheme(), and gum::ApproximationScheme::setPeriodSize().
INLINE void gum::learning::genericBNLearner::setPossibleEdges | ( | const EdgeSet & | set | ) |
assign a set of forbidden edges
Definition at line 311 of file genericBNLearner_inl.h.
References __constraint_PossibleEdges, and gum::learning::StructuralConstraintPossibleEdges::setEdges().
Referenced by setPossibleSkeleton().
INLINE void gum::learning::genericBNLearner::setPossibleSkeleton | ( | const UndiGraph & | skeleton | ) |
assign a set of forbidden edges
Definition at line 315 of file genericBNLearner_inl.h.
References gum::EdgeGraphPart::edges(), and setPossibleEdges().
INLINE void gum::learning::genericBNLearner::setRecordWeight | ( | const std::size_t | i, |
const double | weight | ||
) |
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 162 of file genericBNLearner_inl.h.
References __score_database, and gum::learning::genericBNLearner::Database::setWeight().
INLINE void gum::learning::genericBNLearner::setSliceOrder | ( | const NodeProperty< NodeId > & | slice_order | ) |
sets a partial order on the nodes
slice_order | a NodeProperty given the rank (priority) of nodes in the partial order |
Definition at line 433 of file genericBNLearner_inl.h.
References __constraint_SliceOrder.
Referenced by setSliceOrder().
INLINE void gum::learning::genericBNLearner::setSliceOrder | ( | const std::vector< std::vector< std::string > > & | slices | ) |
sets a partial order on the nodes
slices | the list of list of variable names |
Definition at line 437 of file genericBNLearner_inl.h.
References gum::learning::genericBNLearner::Database::idFromName(), gum::HashTable< Key, Val, Alloc >::insert(), and setSliceOrder().
|
inlinevirtual |
verbosity
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1085 of file genericBNLearner.h.
References gum::learning::K2::approximationScheme(), and gum::ApproximationScheme::setVerbosity().
|
inlinevirtual |
history
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1103 of file genericBNLearner.h.
References __current_algorithm, GUM_ERROR, and gum::ApproximationScheme::stateApproximationScheme().
INLINE void gum::learning::genericBNLearner::use3off2 | ( | ) |
indicate that we wish to use 3off2
Definition at line 224 of file genericBNLearner_inl.h.
References __miic_3off2, __selected_algo, MIIC_THREE_OFF_TWO, and gum::learning::Miic::set3off2Behaviour().
INLINE void gum::learning::genericBNLearner::useAprioriBDeu | ( | double | weight = 1 | ) |
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 494 of file genericBNLearner_inl.h.
References __apriori_type, __setAprioriWeight(), BDEU, checkScoreAprioriCompatibility(), and GUM_ERROR.
INLINE void gum::learning::genericBNLearner::useAprioriDirichlet | ( | const std::string & | filename, |
double | weight = 1 |
||
) |
use the Dirichlet apriori
Definition at line 479 of file genericBNLearner_inl.h.
References __apriori_dbname, __apriori_type, __setAprioriWeight(), checkScoreAprioriCompatibility(), DIRICHLET_FROM_DATABASE, and GUM_ERROR.
INLINE void gum::learning::genericBNLearner::useAprioriSmoothing | ( | double | weight = 1 | ) |
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 467 of file genericBNLearner_inl.h.
References __apriori_type, __setAprioriWeight(), checkScoreAprioriCompatibility(), GUM_ERROR, and SMOOTHING.
std::pair< std::size_t, std::size_t > gum::learning::genericBNLearner::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
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 896 of file genericBNLearner.cpp.
References __ranges, __score_database, gum::learning::genericBNLearner::Database::databaseTable(), GUM_ERROR, and gum::learning::IDatabaseTable< T_DATA, ALLOC >::nbRows().
void gum::learning::genericBNLearner::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
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 __no_apriori, __ranges, __score_database, gum::learning::genericBNLearner::Database::parser(), and gum::learning::Score< ALLOC >::setRanges().
INLINE void gum::learning::genericBNLearner::useEM | ( | const double | epsilon | ) |
use The EM algorithm to learn paramters
if epsilon=0, EM is not used
Definition at line 301 of file genericBNLearner_inl.h.
References __EMepsilon, and epsilon().
INLINE void gum::learning::genericBNLearner::useGreedyHillClimbing | ( | ) |
indicate that we wish to use a greedy hill climbing algorithm
Definition at line 288 of file genericBNLearner_inl.h.
References __selected_algo, and GREEDY_HILL_CLIMBING.
indicate that we wish to use K2
Definition at line 276 of file genericBNLearner_inl.h.
References __K2, __selected_algo, K2, and gum::learning::K2::setOrder().
INLINE void gum::learning::genericBNLearner::useK2 | ( | const std::vector< NodeId > & | order | ) |
indicate that we wish to use K2
Definition at line 282 of file genericBNLearner_inl.h.
References __K2, __selected_algo, K2, and gum::learning::K2::setOrder().
INLINE void gum::learning::genericBNLearner::useLocalSearchWithTabuList | ( | Size | tabu_size = 100 , |
Size | nb_decrease = 2 |
||
) |
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 293 of file genericBNLearner_inl.h.
References __constraint_TabuList, __local_search_with_tabu_list, __selected_algo, LOCAL_SEARCH_WITH_TABU_LIST, gum::learning::LocalSearchWithTabuList::setMaxNbDecreasingChanges(), and gum::learning::StructuralConstraintTabuList::setTabuListSize().
INLINE void gum::learning::genericBNLearner::useMDL | ( | ) |
indicate that we wish to use the MDL correction for 3off2
OperationNotAllowed | when 3off2 is not the selected algorithm |
Definition at line 246 of file genericBNLearner_inl.h.
References __3off2_kmode, __selected_algo, GUM_ERROR, and MIIC_THREE_OFF_TWO.
INLINE void gum::learning::genericBNLearner::useMIIC | ( | ) |
indicate that we wish to use MIIC
Definition at line 230 of file genericBNLearner_inl.h.
References __miic_3off2, __selected_algo, MIIC_THREE_OFF_TWO, and gum::learning::Miic::setMiicBehaviour().
INLINE void gum::learning::genericBNLearner::useNML | ( | ) |
indicate that we wish to use the NML correction for 3off2
OperationNotAllowed | when 3off2 is not the selected algorithm |
Definition at line 236 of file genericBNLearner_inl.h.
References __3off2_kmode, __selected_algo, GUM_ERROR, and MIIC_THREE_OFF_TWO.
INLINE void gum::learning::genericBNLearner::useNoApriori | ( | ) |
use no apriori
Definition at line 461 of file genericBNLearner_inl.h.
References __apriori_type, checkScoreAprioriCompatibility(), and NO_APRIORI.
INLINE void gum::learning::genericBNLearner::useNoCorr | ( | ) |
indicate that we wish to use the NoCorr correction for 3off2
OperationNotAllowed | when 3off2 is not the selected algorithm |
Definition at line 256 of file genericBNLearner_inl.h.
References __3off2_kmode, __selected_algo, GUM_ERROR, and MIIC_THREE_OFF_TWO.
INLINE void gum::learning::genericBNLearner::useScoreAIC | ( | ) |
indicate that we wish to use an AIC score
Definition at line 183 of file genericBNLearner_inl.h.
References __score_type, AIC, and checkScoreAprioriCompatibility().
INLINE void gum::learning::genericBNLearner::useScoreBD | ( | ) |
indicate that we wish to use a BD score
Definition at line 189 of file genericBNLearner_inl.h.
References __score_type, BD, and checkScoreAprioriCompatibility().
INLINE void gum::learning::genericBNLearner::useScoreBDeu | ( | ) |
indicate that we wish to use a BDeu score
Definition at line 195 of file genericBNLearner_inl.h.
References __score_type, BDeu, and checkScoreAprioriCompatibility().
INLINE void gum::learning::genericBNLearner::useScoreBIC | ( | ) |
indicate that we wish to use a BIC score
Definition at line 201 of file genericBNLearner_inl.h.
References __score_type, BIC, and checkScoreAprioriCompatibility().
INLINE void gum::learning::genericBNLearner::useScoreK2 | ( | ) |
indicate that we wish to use a K2 score
Definition at line 207 of file genericBNLearner_inl.h.
References __score_type, checkScoreAprioriCompatibility(), and K2.
INLINE void gum::learning::genericBNLearner::useScoreLog2Likelihood | ( | ) |
indicate that we wish to use a Log2Likelihood score
Definition at line 213 of file genericBNLearner_inl.h.
References __score_type, checkScoreAprioriCompatibility(), and LOG2LIKELIHOOD.
|
inlinevirtual |
verbosity
Implements gum::IApproximationSchemeConfiguration.
Definition at line 1092 of file genericBNLearner.h.
References __current_algorithm, GUM_ERROR, and gum::ApproximationScheme::verbosity().
|
protected |
the penalty used in 3off2
Definition at line 784 of file genericBNLearner.h.
Referenced by __createCorrectedMutualInformation(), operator=(), useMDL(), useNML(), and useNoCorr().
|
protected |
the apriori used
Definition at line 749 of file genericBNLearner.h.
Referenced by __createApriori(), __createParamEstimator(), __createScore(), chi2(), G2(), logLikelihood(), operator=(), and ~genericBNLearner().
|
protected |
the database used by the Dirichlet a priori
Definition at line 803 of file genericBNLearner.h.
Referenced by __createApriori(), __learnDAG(), operator=(), and ~genericBNLearner().
|
protected |
the filename for the Dirichlet a priori, if any
Definition at line 806 of file genericBNLearner.h.
Referenced by __createApriori(), operator=(), and useAprioriDirichlet().
|
protected |
the a priori selected for the score and parameters
Definition at line 746 of file genericBNLearner.h.
Referenced by __createApriori(), __getAprioriType(), __learnDAG(), operator=(), useAprioriBDeu(), useAprioriDirichlet(), useAprioriSmoothing(), and useNoApriori().
|
protected |
the weight of the apriori
Definition at line 754 of file genericBNLearner.h.
Referenced by __createApriori(), __setAprioriWeight(), checkScoreAprioriCompatibility(), and operator=().
|
protected |
the constraint on forbidden arcs
Definition at line 766 of file genericBNLearner.h.
Referenced by __learnDAG(), __prepare_miic_3off2(), addForbiddenArc(), eraseForbiddenArc(), operator=(), and setForbiddenArcs().
|
protected |
the constraint for indegrees
Definition at line 760 of file genericBNLearner.h.
Referenced by __learnDAG(), operator=(), and setMaxIndegree().
|
protected |
the constraint on forbidden arcs
Definition at line 772 of file genericBNLearner.h.
Referenced by __learnDAG(), __prepare_miic_3off2(), addMandatoryArc(), eraseMandatoryArc(), operator=(), and setMandatoryArcs().
|
protected |
the constraint on possible Edges
Definition at line 769 of file genericBNLearner.h.
Referenced by __learnDAG(), addPossibleEdge(), erasePossibleEdge(), and setPossibleEdges().
|
protected |
the constraint for 2TBNs
Definition at line 757 of file genericBNLearner.h.
Referenced by __learnDAG(), operator=(), and setSliceOrder().
|
protected |
the constraint for tabu lists
Definition at line 763 of file genericBNLearner.h.
Referenced by __learnDAG(), operator=(), and useLocalSearchWithTabuList().
|
protected |
Definition at line 812 of file genericBNLearner.h.
Referenced by currentTime(), epsilon(), history(), isEnabledEpsilon(), isEnabledMaxIter(), isEnabledMaxTime(), isEnabledMinEpsilonRate(), maxIter(), maxTime(), minEpsilonRate(), nbrIterations(), operator=(), periodSize(), setCurrentApproximationScheme(), stateApproximationScheme(), and verbosity().
|
protected |
the parametric EM
Definition at line 788 of file genericBNLearner.h.
|
protected |
epsilon for EM. if espilon=0.0 : no EM
Definition at line 740 of file genericBNLearner.h.
Referenced by operator=(), and useEM().
|
protected |
the greedy hill climbing algorithm
Definition at line 791 of file genericBNLearner.h.
Referenced by __learnDAG(), and operator=().
|
protected |
an initial DAG given to learners
Definition at line 809 of file genericBNLearner.h.
Referenced by __learnDAG(), operator=(), and setInitialDAG().
|
protected |
the K2 algorithm
Definition at line 778 of file genericBNLearner.h.
Referenced by __learnDAG(), operator=(), and useK2().
|
protected |
the local search with tabu list algorithm
Definition at line 794 of file genericBNLearner.h.
Referenced by __learnDAG(), operator=(), and useLocalSearchWithTabuList().
|
protected |
the 3off2 algorithm
Definition at line 781 of file genericBNLearner.h.
Referenced by __learnDAG(), __prepare_miic_3off2(), latentVariables(), learnMixedStructure(), operator=(), use3off2(), and useMIIC().
|
protected |
the selected correction for 3off2 and miic
Definition at line 743 of file genericBNLearner.h.
Referenced by __createCorrectedMutualInformation(), __learnDAG(), learnMixedStructure(), operator=(), and ~genericBNLearner().
|
protected |
Definition at line 751 of file genericBNLearner.h.
Referenced by __createCorrectedMutualInformation(), __createParamEstimator(), genericBNLearner(), useDatabaseRanges(), and ~genericBNLearner().
|
protected |
the type of the parameter estimator
Definition at line 737 of file genericBNLearner.h.
Referenced by __createParamEstimator(), and operator=().
|
protected |
the set of rows' ranges within the database in which learning is done
Definition at line 800 of file genericBNLearner.h.
Referenced by __createCorrectedMutualInformation(), __createParamEstimator(), __createScore(), clearDatabaseRanges(), databaseRanges(), operator=(), useCrossValidationFold(), and useDatabaseRanges().
|
protected |
the score used
Definition at line 734 of file genericBNLearner.h.
Referenced by __createParamEstimator(), __createScore(), __learnDAG(), operator=(), and ~genericBNLearner().
|
protected |
the database to be used by the scores and parameter estimators
Definition at line 797 of file genericBNLearner.h.
Referenced by __createApriori(), __createCorrectedMutualInformation(), __createParamEstimator(), __createScore(), __learnDAG(), __prepare_miic_3off2(), chi2(), database(), databaseWeight(), domainSizes(), G2(), genericBNLearner(), hasMissingValues(), idFromName(), learnMixedStructure(), logLikelihood(), nameFromId(), names(), nbCols(), nbRows(), operator=(), recordWeight(), setDatabaseWeight(), setRecordWeight(), useCrossValidationFold(), and useDatabaseRanges().
|
protected |
the score selected for learning
Definition at line 731 of file genericBNLearner.h.
Referenced by __createScore(), checkScoreAprioriCompatibility(), operator=(), useScoreAIC(), useScoreBD(), useScoreBDeu(), useScoreBIC(), useScoreK2(), and useScoreLog2Likelihood().
|
protected |
the selected learning algorithm
Definition at line 775 of file genericBNLearner.h.
Referenced by __learnDAG(), latentVariables(), learnMixedStructure(), operator=(), use3off2(), useGreedyHillClimbing(), useK2(), useLocalSearchWithTabuList(), useMDL(), useMIIC(), useNML(), and useNoCorr().
Progression, error and time.
Definition at line 59 of file IApproximationSchemeConfiguration.h.
Referenced by gum::learning::Miic::_initiation(), gum::learning::Miic::_iteration(), gum::learning::Miic::_orientation_3off2(), gum::learning::Miic::_orientation_latents(), gum::learning::Miic::_orientation_miic(), gum::ApproximationScheme::continueApproximationScheme(), and distributeProgress().
|
inherited |
Criteria messageApproximationScheme.
Definition at line 62 of file IApproximationSchemeConfiguration.h.
Referenced by gum::ApproximationScheme::_stopScheme(), and distributeStop().