aGrUM 3.3.2
a C++ library for (probabilistic) graphical models
gum::learning::BNLearner< GUM_SCALAR > Class Template Referencefinal

A pack of learning algorithms that can easily be used. More...

#include <BNLearner.h>

Inheritance diagram for gum::learning::BNLearner< GUM_SCALAR >:
[legend]
Collaboration diagram for gum::learning::BNLearner< GUM_SCALAR >:
[legend]

Public Types

enum class  ScoreType {
  AIC , BD , BDeu , BIC ,
  fNML , K2 , LOG2LIKELIHOOD , MDL
}
 an enumeration enabling to select easily the score we wish to use More...
enum class  ParamEstimatorType { ML }
 an enumeration to select the type of parameter estimation we shall apply More...
enum class  BNLearnerPriorType {
  NO_prior , SMOOTHING , DIRICHLET_FROM_DATABASE , DIRICHLET_FROM_BAYESNET ,
  BDEU
}
 an enumeration to select the prior More...
enum class  AlgoType {
  K2 , GREEDY_HILL_CLIMBING , LOCAL_SEARCH_WITH_TABU_LIST , MIIC ,
  PC , FCI , EXTENDED_GREEDY_HILL_CLIMBING , GREEDY_THICK_THINNING
}
 an enumeration to select easily the learning algorithm to use More...
enum class  ApproximationSchemeSTATE : char {
  Undefined , Continue , Epsilon , Rate ,
  Limit , TimeLimit , Stopped
}
 The different state of an approximation scheme. More...

Public Member Functions

BayesNet< GUM_SCALAR > learnBN ()
 learn a Bayes Net from a file (must have read the db before)
BayesNet< GUM_SCALAR > learnParameters (const DAG &dag, bool takeIntoAccountScore=true)
 learns a BN (its parameters) with the structure passed in argument
BayesNet< GUM_SCALAR > learnParameters (const BayesNet< GUM_SCALAR > &bn, bool takeIntoAccountScore=true)
 learns a BN (its parameters) with the BN structure passed in argument, EM being initialized by this argument
BayesNet< GUM_SCALAR > learnParameters (bool take_into_account_score=true)
 learns a BN (its parameters) when its structure is known
std::string toString () const
std::vector< std::tuple< std::string, std::string, std::string > > state () const
void copyState (const BNLearner< GUM_SCALAR > &learner)
 copy the states of the BNLearner
BNLearner< GUM_SCALAR > & setInitialDAG (const DAG &dag)
BNLearner< GUM_SCALAR > & useEM (const double epsilon, const double noise)
 use The EM algorithm to learn parameters
BNLearner< GUM_SCALAR > & useEM (const double epsilon)
 use The EM algorithm to learn parameters with the default noise (key emNoise of the section learning of gum::Configuration)
BNLearner< GUM_SCALAR > & useEMWithRateCriterion (const double epsilon, const double noise)
 use The EM algorithm to learn parameters with the rate stopping criterion
BNLearner< GUM_SCALAR > & useEMWithRateCriterion (const double epsilon)
 use The EM algorithm with the rate stopping criterion and the default noise (key emNoise)
BNLearner< GUM_SCALAR > & useEMWithDiffCriterion (const double epsilon, const double noise)
 use The EM algorithm to learn parameters with the diff stopping criterion
BNLearner< GUM_SCALAR > & useEMWithDiffCriterion (const double epsilon)
 use The EM algorithm with the diff stopping criterion and the default noise (key emNoise)
BNLearner< GUM_SCALAR > & forbidEM ()
 prevent using the EM algorithm for parameter learning
BNLearner< GUM_SCALAR > & EMsetEpsilon (const double eps)
 sets the stopping criterion of EM as being the minimal difference between two consecutive log-likelihoods
BNLearner< GUM_SCALAR > & EMdisableEpsilon ()
 Disable the min log-likelihood diff stopping criterion.
BNLearner< GUM_SCALAR > & EMenableEpsilon ()
 Enable the log-likelihood min diff stopping criterion in EM.
BNLearner< GUM_SCALAR > & EMsetMinEpsilonRate (const double rate)
 sets the stopping criterion of EM as being the minimal log-likelihood's evolution rate
BNLearner< GUM_SCALAR > & EMdisableMinEpsilonRate ()
 Disable the log-likelihood evolution rate stopping criterion.
BNLearner< GUM_SCALAR > & EMenableMinEpsilonRate ()
 Enable the log-likelihood evolution rate stopping criterion.
BNLearner< GUM_SCALAR > & EMsetMaxIter (const Size max)
 add a max iteration stopping criterion
BNLearner< GUM_SCALAR > & EMdisableMaxIter ()
 Disable stopping criterion on max iterations.
BNLearner< GUM_SCALAR > & EMenableMaxIter ()
 Enable stopping criterion on max iterations.
BNLearner< GUM_SCALAR > & EMsetMaxTime (const double timeout)
 add a stopping criterion on timeout
BNLearner< GUM_SCALAR > & EMdisableMaxTime ()
 Disable EM's timeout stopping criterion.
BNLearner< GUM_SCALAR > & EMenableMaxTime ()
 enable EM's timeout stopping criterion
BNLearner< GUM_SCALAR > & EMsetPeriodSize (const Size p)
 how many samples between 2 stoppings isEnabled
BNLearner< GUM_SCALAR > & EMsetVerbosity (const bool v)
 sets or unsets EM's verbosity
BNLearner< GUM_SCALAR > & useScoreAIC ()
BNLearner< GUM_SCALAR > & useScoreBD ()
BNLearner< GUM_SCALAR > & useScoreBDeu ()
BNLearner< GUM_SCALAR > & useScoreBIC ()
BNLearner< GUM_SCALAR > & useScoreK2 ()
BNLearner< GUM_SCALAR > & useScoreLog2Likelihood ()
BNLearner< GUM_SCALAR > & useNoPrior ()
BNLearner< GUM_SCALAR > & useBDeuPrior (double weight)
BNLearner< GUM_SCALAR > & useBDeuPrior ()
 use the BDeu prior with the default weight (key priorWeight of the section learning)
BNLearner< GUM_SCALAR > & useSmoothingPrior (double weight)
BNLearner< GUM_SCALAR > & useSmoothingPrior ()
 use the smoothing prior with the default weight (key priorWeight)
BNLearner< GUM_SCALAR > & useDirichletPrior (std::string_view filename, double weight)
BNLearner< GUM_SCALAR > & useDirichletPrior (std::string_view filename)
 use the Dirichlet prior from a database with the default weight (key priorWeight)
BNLearner< GUM_SCALAR > & useDirichletPrior (const gum::BayesNet< GUM_SCALAR > &bn, double weight)
BNLearner< GUM_SCALAR > & useDirichletPrior (const gum::BayesNet< GUM_SCALAR > &bn)
 use the Dirichlet prior from a BN with the default weight (key priorWeight)
BNLearner< GUM_SCALAR > & useGreedyHillClimbing ()
BNLearner< GUM_SCALAR > & useExtendedGreedyHillClimbing ()
BNLearner< GUM_SCALAR > & useGreedyThickThinning ()
BNLearner< GUM_SCALAR > & setGreedyThickThinningReversals (bool allow)
bool greedyThickThinningReversals () const
BNLearner< GUM_SCALAR > & useLocalSearchWithTabuList (Size tabu_size, Size nb_decrease)
BNLearner< GUM_SCALAR > & useLocalSearchWithTabuList (Size tabu_size)
 use a local search with tabu list, with the default number of decreasing changes (key tabuNbDecrease of the section learning of gum::Configuration)
BNLearner< GUM_SCALAR > & useLocalSearchWithTabuList ()
 use a local search with tabu list and the default parameters (keys tabuListSize and tabuNbDecrease)
BNLearner< GUM_SCALAR > & useK2 (const Sequence< NodeId > &order)
BNLearner< GUM_SCALAR > & useK2 (const std::vector< NodeId > &order)
BNLearner< GUM_SCALAR > & useMIIC ()
BNLearner< GUM_SCALAR > & usePC ()
BNLearner< GUM_SCALAR > & useFCI ()
BNLearner< GUM_SCALAR > & useFCIChi2Test ()
BNLearner< GUM_SCALAR > & useFCIG2Test ()
BNLearner< GUM_SCALAR > & setFCIAlpha (double alpha)
BNLearner< GUM_SCALAR > & setFCIMaxPathLength (Size max_len)
BNLearner< GUM_SCALAR > & setFCIExhaustiveSepSet (bool exhaustive)
bool fciExhaustiveSepSet () const
BNLearner< GUM_SCALAR > & useChi2Test ()
BNLearner< GUM_SCALAR > & useG2Test ()
BNLearner< GUM_SCALAR > & setPCAlpha (double alpha)
BNLearner< GUM_SCALAR > & setPCStable (bool stable)
BNLearner< GUM_SCALAR > & setPCMaxCondSetSize (Size max_k)
BNLearner< GUM_SCALAR > & setPCUnshieldedColliderSorted (bool sorted)
BNLearner< GUM_SCALAR > & useNMLCorrection ()
BNLearner< GUM_SCALAR > & useMDLCorrection ()
BNLearner< GUM_SCALAR > & useNoCorrection ()
BNLearner< GUM_SCALAR > & setMaxIndegree (Size max_indegree)
BNLearner< GUM_SCALAR > & setSliceOrder (const NodeProperty< NodeId > &slice_order)
BNLearner< GUM_SCALAR > & setSliceOrder (const std::vector< std::vector< std::string > > &slices)
BNLearner< GUM_SCALAR > & setTotalOrder (const std::vector< std::string > &order)
BNLearner< GUM_SCALAR > & setTotalOrder (const Sequence< NodeId > &order)
BNLearner< GUM_SCALAR > & setForbiddenArcs (const ArcSet &set)
BNLearner< GUM_SCALAR > & addForbiddenArc (const Arc &arc)
BNLearner< GUM_SCALAR > & addForbiddenArc (NodeId tail, NodeId head)
BNLearner< GUM_SCALAR > & addForbiddenArc (std::string_view tail, std::string_view head)
BNLearner< GUM_SCALAR > & eraseForbiddenArc (const Arc &arc)
BNLearner< GUM_SCALAR > & eraseForbiddenArc (NodeId tail, NodeId head)
BNLearner< GUM_SCALAR > & eraseForbiddenArc (std::string_view tail, std::string_view head)
BNLearner< GUM_SCALAR > & addMandatoryArc (const Arc &arc)
BNLearner< GUM_SCALAR > & addMandatoryArc (NodeId tail, NodeId head)
BNLearner< GUM_SCALAR > & addMandatoryArc (std::string_view tail, std::string_view head)
BNLearner< GUM_SCALAR > & eraseMandatoryArc (const Arc &arc)
BNLearner< GUM_SCALAR > & eraseMandatoryArc (NodeId tail, NodeId head)
BNLearner< GUM_SCALAR > & eraseMandatoryArc (std::string_view tail, std::string_view head)
BNLearner< GUM_SCALAR > & addPossibleEdge (const Edge &edge)
BNLearner< GUM_SCALAR > & addPossibleEdge (NodeId tail, NodeId head)
BNLearner< GUM_SCALAR > & addPossibleEdge (std::string_view tail, std::string_view head)
BNLearner< GUM_SCALAR > & erasePossibleEdge (const Edge &edge)
BNLearner< GUM_SCALAR > & erasePossibleEdge (NodeId tail, NodeId head)
BNLearner< GUM_SCALAR > & erasePossibleEdge (std::string_view tail, std::string_view head)
BNLearner< GUM_SCALAR > & setMandatoryArcs (const ArcSet &set)
BNLearner< GUM_SCALAR > & setPossibleEdges (const EdgeSet &set)
BNLearner< GUM_SCALAR > & setPossibleSkeleton (const UndiGraph &skeleton)
BNLearner< GUM_SCALAR > & addNoParentNode (NodeId node)
BNLearner< GUM_SCALAR > & addNoParentNode (std::string_view name)
BNLearner< GUM_SCALAR > & eraseNoParentNode (NodeId node)
BNLearner< GUM_SCALAR > & eraseNoParentNode (std::string_view name)
BNLearner< GUM_SCALAR > & addNoChildrenNode (NodeId node)
BNLearner< GUM_SCALAR > & addNoChildrenNode (std::string_view name)
BNLearner< GUM_SCALAR > & eraseNoChildrenNode (NodeId node)
BNLearner< GUM_SCALAR > & eraseNoChildrenNode (std::string_view name)
BNLearner< GUM_SCALAR > & allowArcAdditions (bool allow)
BNLearner< GUM_SCALAR > & allowArcDeletions (bool allow)
BNLearner< GUM_SCALAR > & allowArcReversals (bool allow)
BNLearner< GUM_SCALAR > & allowArcTriangleDeletions (bool allow)
bool isConstraintBased () const
bool isScoreBased () const
Size EMPeriodSize () const
void unsetTotalOrder ()
 removes the current total ordering constraint, if any
Constructors / Destructors
 BNLearner (std::string_view filename, const std::vector< std::string > &missingSymbols={"?"}, const bool induceTypes=true)
 default constructor
 BNLearner (const DatabaseTable &db)
 default constructor
 BNLearner (std::string_view filename, const gum::BayesNet< GUM_SCALAR > &src, const std::vector< std::string > &missing_symbols={"?"})
 Wrapper for BNLearner (filename,modalities,parse_database) using a bn to find those modalities and nodeids.
 BNLearner (const BNLearner &)
 copy constructor
 BNLearner (BNLearner &&)
 move constructor
 ~BNLearner () override
 destructor
Operators
BNLearner & operator= (const BNLearner &)
 copy operator
BNLearner & operator= (BNLearner &&) noexcept
 move operator
Accessors / Modifiers
DAG learnDAG ()
 learn a structure from a file (must have read the db before)
PDAG learnPDAG ()
 learn a partial structure from a file (must have read the db before and must have selected miic)
PAG learnPAG ()
 learn a PAG — only valid when useFCI() has been called
DAG initialDAG ()
 returns the initial DAG structure
const std::vector< std::string > & names () const
 returns the names of the variables in the database
const std::vector< std::size_t > & domainSizes () const
 returns the domain sizes of the variables in the database
Size domainSize (NodeId var) const
 learn a structure from a file (must have read the db before)
Size domainSize (std::string_view var) const
 learn a structure from a file (must have read the db before)
NodeId idFromName (std::string_view var_name) const
 returns the node id corresponding to a variable name
const DatabaseTable & database () const
 returns the database used by the BNLearner
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
void setRecordWeight (const std::size_t i, const double weight)
 sets the weight of the ith record of the database
double recordWeight (const std::size_t i) const
 returns the weight of the ith record
double databaseWeight () const
 returns the weight of the whole database
const std::string & nameFromId (NodeId id) const
 returns the variable name corresponding to a given node id
void useDatabaseRanges (const std::vector< std::pair< std::size_t, std::size_t > > &new_ranges)
 use a new set of database rows' ranges to perform learning
void clearDatabaseRanges ()
 reset the ranges to the one range corresponding to the whole database
const std::vector< std::pair< std::size_t, std::size_t > > & databaseRanges () const
 returns the current database rows' ranges used for learning
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
std::pair< double, double > chi2 (NodeId id1, NodeId id2, const std::vector< NodeId > &knowing={})
 Return the <statistic,pvalue> pair for chi2 test in the database.
std::pair< double, double > chi2 (std::string_view name1, std::string_view name2, const std::vector< std::string > &knowing={})
 Return the <statistic,pvalue> pair for the BNLearner.
std::pair< double, double > G2 (NodeId id1, NodeId id2, const std::vector< NodeId > &knowing={})
 Return the <statistic,pvalue> pair for for G2 test in the database.
std::pair< double, double > G2 (std::string_view name1, std::string_view name2, const std::vector< std::string > &knowing={})
 Return the <statistic,pvalue> pair for for G2 test in the database.
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.
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.
double mutualInformation (NodeId id1, NodeId id2, const std::vector< NodeId > &knowing={})
 Return the mutual information of id1 and id2 in the base, conditioned by knowing for the BNLearner.
double mutualInformation (std::string_view var1, std::string_view var2, const std::vector< std::string > &knowing={})
 Return the mutual information of var1 and var2 in the base, conditioned by knowing for the BNLearner.
double correctedMutualInformation (NodeId id1, NodeId id2, const std::vector< NodeId > &knowing={})
 Return the mutual information of id1 and id2 in the base, conditioned by knowing for the BNLearner.
double correctedMutualInformation (std::string_view var1, std::string_view var2, const std::vector< std::string > &knowing={})
 Return the mutual information of var1 and var2 in the base, conditioned by knowing for the BNLearner.
double score (NodeId vars, const std::vector< NodeId > &knowing={})
 Return the value of the score currently in use by the BNLearner of a variable given a set of other variables.
double score (std::string_view vars, const std::vector< std::string > &knowing={})
 Return the value of the score currently in use by the BNLearner of a variable given a set of other variables The score used is the one currently selected in the BNLearner.
std::vector< double > rawPseudoCount (const std::vector< NodeId > &vars)
 Return the pseudo-counts of NodeIds vars in the base in a raw array.
std::vector< double > rawPseudoCount (const std::vector< std::string > &vars)
 Return the pseudoconts of vars in the base in a raw array.
Size nbCols () const
Size nbRows () const
bool isUsingEM () const
 indicates whether we use EM for parameter learning
EMApproximationScheme & EM ()
 returns the EM parameter learning approximation scheme if EM is enabled
ApproximationSchemeSTATE EMState () const
 returns the state of the last EM algorithm executed
std::string EMStateMessage () const
 returns the state of the EM algorithm
bool hasMissingValues () const
 returns true if the learner's database has missing values
Score selection
void useScorefNML ()
 indicate that we wish to use a fNML score
void useScoreMDL ()
 indicate that we wish to use a MDL score
a prior selection / parameterization
std::string checkScorePriorCompatibility () const
 checks whether the current score and prior are compatible
MIIC parameterization and specific results
std::vector< Arc > latentVariables () const
 get the list of arcs hiding latent variables
Accessors / Modifiers for adding constraints on learning
void unsetSliceOrder ()
 removes the slice order constraint
Multithreading
void setNumberOfThreads (Size nb) override
 sets the number max of threads that can be used
redistribute signals AND implementation of interface
void setCurrentApproximationScheme (const ApproximationScheme *approximationScheme)
 {@ /// distribute signals
void distributeProgress (const ApproximationScheme *approximationScheme, Size pourcent, double error, double time)
 {@ /// distribute signals
void distributeStop (const ApproximationScheme *approximationScheme, std::string_view message)
 distribute signals
void setEpsilon (double eps) override
 Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)| If the criterion was disabled it will be enabled.
double epsilon () const override
 Get the value of epsilon.
void disableEpsilon () override
 Disable stopping criterion on epsilon.
void enableEpsilon () override
 Enable stopping criterion on epsilon.
bool isEnabledEpsilon () const override
void setMinEpsilonRate (double rate) override
 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.
double minEpsilonRate () const override
 Get the value of the minimal epsilon rate.
void disableMinEpsilonRate () override
 Disable stopping criterion on epsilon rate.
void enableMinEpsilonRate () override
 Enable stopping criterion on epsilon rate.
bool isEnabledMinEpsilonRate () const override
void setMaxIter (Size max) override
 stopping criterion on number of iterationsIf the criterion was disabled it will be enabled
Size maxIter () const override
void disableMaxIter () override
 Disable stopping criterion on max iterations.
void enableMaxIter () override
 Enable stopping criterion on max iterations.
bool isEnabledMaxIter () const override
void setMaxTime (double timeout) override
 stopping criterion on timeout If the criterion was disabled it will be enabled
double maxTime () const override
 returns the timeout (in seconds)
double currentTime () const override
 get the current running time in second (double)
void disableMaxTime () override
 Disable stopping criterion on timeout.
void enableMaxTime () override
 stopping criterion on timeout If the criterion was disabled it will be enabled
bool isEnabledMaxTime () const override
void setPeriodSize (Size p) override
 how many samples between 2 stopping isEnableds
Size periodSize () const override
 how many samples between 2 stopping isEnableds
void setVerbosity (bool v) override
 verbosity
bool verbosity () const override
 verbosity
ApproximationSchemeSTATE stateApproximationScheme () const override
 history
Size nbrIterations () const override
const std::vector< double > & history () const override
EM approximation scheme for parameter learning
double EMEpsilon () const
 Get the value of EM's min diff epsilon.
bool EMisEnabledEpsilon () const
 return true if EM's stopping criterion is the log-likelihood min diff
double EMMinEpsilonRate () const
 Get the value of the minimal log-likelihood evolution rate of EM.
bool EMisEnabledMinEpsilonRate () const
Size EMMaxIter () const
 return the max number of iterations criterion
bool EMisEnabledMaxIter () const
double EMMaxTime () const
 @brief returns EM's timeout (in milliseconds)
double EMCurrentTime () const
 get the current running time in second (double)
bool EMisEnabledMaxTime () const
bool EMVerbosity () const
 returns the EM's verbosity status
ApproximationSchemeSTATE EMStateApproximationScheme () const
 get the current state of EM
Size EMnbrIterations () const
 returns the number of iterations performed by the last EM execution
const std::vector< double > & EMHistory () const
 returns the history of the last EM execution
Getters and setters
std::string messageApproximationScheme () const
 Returns the approximation scheme message.
Accessors/Modifiers
Size getNumberOfThreads () const override
 returns the current max number of threads used by the class containing this ThreadNumberManager
bool isGumNumberOfThreadsOverriden () const override
 indicates whether the class containing this ThreadNumberManager set its own number of threads

Static Public Member Functions

Learning algorithm selection
static AlgoType preferredAlgo ()
 the algorithm used by the learners when none is selected explicitly

Public Attributes

Signaler< Size, double, double > onProgress
 Progression, error and time.
Signaler< std::string_view > onStop
 Criteria messageApproximationScheme.

Protected Types

enum class  IndepTestType { Chi2 , G2 }
 independence test type for PC More...

Protected Member Functions

void createPrior_ () override
 create the prior used for learning
PAG learnPAG_ ()
PDAG learnPDAG_ ()
void _setPriorWeight_ (double weight)
 sets the prior weight
void createScore_ ()
 create the score used for learning
ParamEstimator * createParamEstimator_ (const DBRowGeneratorParser &parser, bool take_into_account_score=true)
 create the parameter estimator used for learning
DAG learnDag_ ()
 returns the DAG learnt
MixedGraph prepareMiic_ ()
 prepares the initial graph for miic
MixedGraph preparePC_ ()
 prepares the initial graph and independence test for PC
MixedGraph prepareFCI_ ()
 prepares the initial graph and independence test for FCI
PriorType getPriorType_ () const
 returns the type (as a string) of a given prior
void createCorrectedMutualInformation_ ()
 create the Corrected Mutual Information instance for Miic

Static Protected Member Functions

static DatabaseTable readFile_ (std::string_view filename, const std::vector< std::string > &missing_symbols)
 reads a file and returns a databaseVectInRam
static void isCSVFileName_ (std::string_view filename)
 checks whether the extension of a CSV filename is correct

Protected Attributes

bool inducedTypes_ {false}
 the policy for typing variables
ScoreType scoreType_ {ScoreType::BDeu}
 the score selected for learning
Score * score_ {nullptr}
 the score used
ParamEstimatorType paramEstimatorType_ {ParamEstimatorType::ML}
 the type of the parameter estimator
bool useEM_ {false}
 a Boolean indicating whether we should use EM for parameter learning or not
CorrectedMutualInformation * mutualInfo_ {nullptr}
 the selected correction for miic
BNLearnerPriorType priorType_ {BNLearnerPriorType::NO_prior}
 the a priorselected for the score and parameters
Prior * prior_ {nullptr}
 the prior used
NoPrior * noPrior_ {nullptr}
double priorWeight_ {1.0f}
 the weight of the prior. It is always written by the useXxxPrior() methods, which read learning.priorWeight when no weight is given.
StructuralConstraintSliceOrder constraintSliceOrder_
 the constraint for 2TBNs
StructuralConstraintTotalOrder constraintTotalOrder_
 the total order ing constraint
StructuralConstraintIndegree constraintIndegree_
 the constraint for indegrees
StructuralConstraintTabuList constraintTabuList_
 the constraint for tabu lists
StructuralConstraintForbiddenArcs constraintForbiddenArcs_
 the constraint on forbidden arcs
StructuralConstraintPossibleEdges constraintPossibleEdges_
 the constraint on possible Edges
StructuralConstraintMandatoryArcs constraintMandatoryArcs_
 the constraint on mandatory arcs
StructuralConstraintNoParentNodes constraintNoParentNodes_
 the constraint on no parent nodes
StructuralConstraintNoChildrenNodes constraintNoChildrenNodes_
 the constraint on no children nodes
AlgoType selectedAlgo_ {preferredAlgo()}
 the learning algorithm ; it is initialized from the configuration, see preferredAlgo()
bool allowArcAdditions_ {true}
 whether we allow or not arc additions during learning
bool allowArcDeletions_ {true}
 whether we allow or not arc deletions during learning
bool allowArcReversals_ {true}
 whether we allow or not arc reversals during learning
bool allowArcTriangleDeletions_ {true}
 whether we allow or not arc deletions during learning
K2 algoK2_
 the K2 algorithm
Miic algoMiic_
 the Constraint MIIC algorithm
CorrectedMutualInformation::KModeTypes kmodeMiic_
 the penalty used in MIIC
gum::learning::PC algoPC_
 the PC algorithm
IndepTestType indepTestTypePC_ {IndepTestType::Chi2}
IndependenceTest * indepTestPC_ {nullptr}
 owned independence test object for PC (rebuilt before each learn call)
double alphaPc_ {gum::config().typed< double >("learning", "alpha")}
 PC parameters the threshold of the tests ; it is initialized from the key learning.alpha.
bool stablePc_ {true}
Size maxCondSetSizePc_ {Size(-1)}
bool sortedUCPc_ {false}
gum::learning::FCI algoFCI_
 the FCI algorithm
IndepTestType indepTestTypeFCI_ {IndepTestType::Chi2}
 independence test type for FCI (reuses IndepTestType defined above)
IndependenceTest * indepTestFCI_ {nullptr}
 owned independence test object for FCI (rebuilt before each learn call)
double alphaFci_ {gum::config().typed< double >("learning", "alpha")}
 FCI parameters the threshold of the tests ; it is initialized from the key learning.alpha.
Size maxPathLengthFci_ {Size(-1)}
bool exhaustiveSepSetFci_ {false}
DAG2BNLearner dag2BN_
 the parametric EM
GreedyHillClimbing greedyHillClimbing_
 the greedy hill climbing algorithm
GreedyHillClimbing extendedGreedyHillClimbing_
 the extended greedy hill climbing
GreedyThickThinning greedyThickThinning_
 the greedy thick-thinning algorithm
LocalSearchWithTabuList localSearchWithTabuList_
 the local search with tabu list algorithm
Database scoreDatabase_
 the database to be used by the scores and parameter estimators
std::vector< std::pair< std::size_t, std::size_t > > ranges_
 the set of rows' ranges within the database in which learning is done
Database * priorDatabase_ {nullptr}
 the database used by the Dirichlet a priori
std::string priorDbname_
 the filename for the Dirichlet a priori, if any
DAG initialDag_
 an initial DAG given to learners
std::string filename_ {"-"}
 the filename database
Size tabuListSize_ {100}
Size nbDecreasingChanges_ {2}
const ApproximationScheme * currentAlgorithm_ {nullptr}

Private Member Functions

NodeProperty< Sequence< std::string > > _labelsFromBN_ (std::string_view filename, const BayesNet< GUM_SCALAR > &src)
 read the first line of a file to find column names
void _checkDAGCompatibility_ (const DAG &dag)
 check that the database contains the nodes of the dag, else raise an exception
BayesNet< GUM_SCALAR > _learnParameters_ (const DAG &dag, bool takeIntoAccountScore)
 learns a BN (its parameters) with the structure passed in argument using a single pass estimation (not EM)
std::pair< std::shared_ptr< ParamEstimator >, std::shared_ptr< ParamEstimator > > _initializeEMParameterLearning_ (const DAG &dag, bool takeIntoAccountScore)
 initializes EM and returns a pair containing, first, a bootstrap estimator and, second, the EM estimator
BayesNet< GUM_SCALAR > _learnParametersWithEM_ (const DAG &dag, bool takeIntoAccountScore)
 learns a BN (its parameters) with the structure passed in argument using the EM algorithm initialized by the BNLearner
BayesNet< GUM_SCALAR > _learnParametersWithEM_ (const BayesNet< GUM_SCALAR > &bn, bool takeIntoAccountScore)
 learns a BN (its parameters) with the structure passed in argument using the EM algorithm initialized by the Bayes net passed in argument

Private Attributes

BayesNet< GUM_SCALAR > _prior_bn_
Size _nb_threads_ {0}
 the max number of threads used by the class

Detailed Description

template<GUM_Numeric GUM_SCALAR>
class gum::learning::BNLearner< GUM_SCALAR >

A pack of learning algorithms that can easily be used.

The pack currently contains K2, GreedyHillClimbing and LocalSearchWithTabuList

Definition at line 73 of file BNLearner.h.

Member Enumeration Documentation

◆ AlgoType

enum class gum::learning::IBNLearner::AlgoType
stronginherited

an enumeration to select easily the learning algorithm to use

Enumerator
K2 
GREEDY_HILL_CLIMBING 
LOCAL_SEARCH_WITH_TABU_LIST 
MIIC 
PC 
FCI 
EXTENDED_GREEDY_HILL_CLIMBING 
GREEDY_THICK_THINNING 

Definition at line 126 of file IBNLearner.h.

126 {
127 K2,
128 GREEDY_HILL_CLIMBING,
129 LOCAL_SEARCH_WITH_TABU_LIST,
130 MIIC,
131 PC,
132 FCI,
133 EXTENDED_GREEDY_HILL_CLIMBING,
134 GREEDY_THICK_THINNING
135 };

◆ ApproximationSchemeSTATE

The different state of an approximation scheme.

Enumerator
Undefined 
Continue 
Epsilon 
Rate 
Limit 
TimeLimit 
Stopped 

Definition at line 87 of file IApproximationSchemeConfiguration.h.

87 : char {
88 Undefined,
89 Continue,
90 Epsilon,
91 Rate,
92 Limit,
93 TimeLimit,
94 Stopped
95 };

◆ BNLearnerPriorType

an enumeration to select the prior

Enumerator
NO_prior 
SMOOTHING 
DIRICHLET_FROM_DATABASE 
DIRICHLET_FROM_BAYESNET 
BDEU 

Definition at line 117 of file IBNLearner.h.

117 {
118 NO_prior,
119 SMOOTHING,
120 DIRICHLET_FROM_DATABASE,
121 DIRICHLET_FROM_BAYESNET,
122 BDEU
123 };

◆ IndepTestType

enum class gum::learning::IBNLearner::IndepTestType
strongprotectedinherited

independence test type for PC

Enumerator
Chi2 
G2 

Definition at line 1249 of file IBNLearner.h.

1249{ Chi2, G2 };

◆ ParamEstimatorType

an enumeration to select the type of parameter estimation we shall apply

Enumerator
ML 

Definition at line 114 of file IBNLearner.h.

114{ ML };

◆ ScoreType

enum class gum::learning::IBNLearner::ScoreType
stronginherited

an enumeration enabling to select easily the score we wish to use

Enumerator
AIC 
BD 
BDeu 
BIC 
fNML 
K2 
LOG2LIKELIHOOD 
MDL 

Definition at line 110 of file IBNLearner.h.

110{ AIC, BD, BDeu, BIC, fNML, K2, LOG2LIKELIHOOD, MDL };

Constructor & Destructor Documentation

◆ BNLearner() [1/5]

template<GUM_Numeric GUM_SCALAR>
gum::learning::BNLearner< GUM_SCALAR >::BNLearner ( std::string_view filename,
const std::vector< std::string > & missingSymbols = {"?"},
const bool induceTypes = true )

default constructor

read the database file for the score / parameter estimation and var names

Parameters
filenamethe name of a CSV file containing the dataset
missingSymbolsthe set of symbols in the CSV that should be interpreted as missing values
induceTypesBy default, all the values in the dataset are interpreted as "labels", i.e., as categorical values. But if some columns of the dataset have only numerical values, it would certainly be better to tag them as corresponding to integer, range or continuous variables. By setting induceTypes to true, this is precisely what the BNLearner will do.

Referenced by BNLearner(), BNLearner(), addForbiddenArc(), addForbiddenArc(), addForbiddenArc(), addMandatoryArc(), addMandatoryArc(), addMandatoryArc(), addNoChildrenNode(), addNoChildrenNode(), addNoParentNode(), addNoParentNode(), addPossibleEdge(), addPossibleEdge(), addPossibleEdge(), allowArcAdditions(), allowArcDeletions(), allowArcReversals(), allowArcTriangleDeletions(), copyState(), EMdisableEpsilon(), EMdisableMaxIter(), EMdisableMaxTime(), EMdisableMinEpsilonRate(), EMenableEpsilon(), EMenableMaxIter(), EMenableMaxTime(), EMenableMinEpsilonRate(), EMsetEpsilon(), EMsetMaxIter(), EMsetMaxTime(), EMsetMinEpsilonRate(), EMsetPeriodSize(), EMsetVerbosity(), eraseForbiddenArc(), eraseForbiddenArc(), eraseForbiddenArc(), eraseMandatoryArc(), eraseMandatoryArc(), eraseMandatoryArc(), eraseNoChildrenNode(), eraseNoChildrenNode(), eraseNoParentNode(), eraseNoParentNode(), erasePossibleEdge(), erasePossibleEdge(), erasePossibleEdge(), forbidEM(), operator=(), operator=(), setFCIAlpha(), setFCIExhaustiveSepSet(), setFCIMaxPathLength(), setForbiddenArcs(), setGreedyThickThinningReversals(), setInitialDAG(), setMandatoryArcs(), setMaxIndegree(), setPCAlpha(), setPCMaxCondSetSize(), setPCStable(), setPCUnshieldedColliderSorted(), setPossibleEdges(), setPossibleSkeleton(), setSliceOrder(), setSliceOrder(), setTotalOrder(), setTotalOrder(), useBDeuPrior(), useBDeuPrior(), useChi2Test(), useDirichletPrior(), useDirichletPrior(), useDirichletPrior(), useDirichletPrior(), useEM(), useEM(), useEMWithDiffCriterion(), useEMWithDiffCriterion(), useEMWithRateCriterion(), useEMWithRateCriterion(), useExtendedGreedyHillClimbing(), useFCI(), useFCIChi2Test(), useFCIG2Test(), useG2Test(), useGreedyHillClimbing(), useGreedyThickThinning(), useK2(), useK2(), useLocalSearchWithTabuList(), useLocalSearchWithTabuList(), useLocalSearchWithTabuList(), useMDLCorrection(), useMIIC(), useNMLCorrection(), useNoCorrection(), useNoPrior(), usePC(), useScoreAIC(), useScoreBD(), useScoreBDeu(), useScoreBIC(), useScoreK2(), useScoreLog2Likelihood(), useSmoothingPrior(), and useSmoothingPrior().

◆ BNLearner() [2/5]

template<GUM_Numeric GUM_SCALAR>
gum::learning::BNLearner< GUM_SCALAR >::BNLearner ( const DatabaseTable & db)

default constructor

read the database file for the score / parameter estimation and var names

Parameters
dban already initialized database table that is used to fill the Database

◆ BNLearner() [3/5]

template<GUM_Numeric GUM_SCALAR>
gum::learning::BNLearner< GUM_SCALAR >::BNLearner ( std::string_view filename,
const gum::BayesNet< GUM_SCALAR > & src,
const std::vector< std::string > & missing_symbols = {"?"} )

Wrapper for BNLearner (filename,modalities,parse_database) using a bn to find those modalities and nodeids.

◆ BNLearner() [4/5]

template<GUM_Numeric GUM_SCALAR>
gum::learning::BNLearner< GUM_SCALAR >::BNLearner ( const BNLearner< GUM_SCALAR > & )

copy constructor

References BNLearner().

Here is the call graph for this function:

◆ BNLearner() [5/5]

template<GUM_Numeric GUM_SCALAR>
gum::learning::BNLearner< GUM_SCALAR >::BNLearner ( BNLearner< GUM_SCALAR > && )

move constructor

References BNLearner().

Here is the call graph for this function:

◆ ~BNLearner()

template<GUM_Numeric GUM_SCALAR>
gum::learning::BNLearner< GUM_SCALAR >::~BNLearner ( )
override

destructor

Member Function Documentation

◆ _checkDAGCompatibility_()

template<GUM_Numeric GUM_SCALAR>
void gum::learning::BNLearner< GUM_SCALAR >::_checkDAGCompatibility_ ( const DAG & dag)
private

check that the database contains the nodes of the dag, else raise an exception

Exceptions
MissingVariableInDatabaseif a variable of the BN is not found in the database.
Returns
nothing if all the nodes of the dag belong to the dataset

References _checkDAGCompatibility_().

Referenced by _checkDAGCompatibility_().

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

◆ _initializeEMParameterLearning_()

template<GUM_Numeric GUM_SCALAR>
std::pair< std::shared_ptr< ParamEstimator >, std::shared_ptr< ParamEstimator > > gum::learning::BNLearner< GUM_SCALAR >::_initializeEMParameterLearning_ ( const DAG & dag,
bool takeIntoAccountScore )
private

initializes EM and returns a pair containing, first, a bootstrap estimator and, second, the EM estimator

Parameters
dagthe graphical structure of the BN learnt by EM
takeIntoAccountScoreThe 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 prior (like K2 which has a 1-smoothing prior), it is important to also take into account this implicit prior for parameter learning. By default, if a score exists, we will learn parameters by taking into account the prior specified by methods usePriorXXX () + the implicit prior of the score, else we just take into account the prior specified by usePriorXXX ()
Returns
a pair of estimators. The first one is used to fill the CPTs of the returned BN in order to initialize EM. It fills them using the database records without taking into account the missing values. The second estimator is the one used by all the subsequent iterations of the EM algorithm.

References _initializeEMParameterLearning_().

Referenced by _initializeEMParameterLearning_().

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

◆ _labelsFromBN_()

template<GUM_Numeric GUM_SCALAR>
NodeProperty< Sequence< std::string > > gum::learning::BNLearner< GUM_SCALAR >::_labelsFromBN_ ( std::string_view filename,
const BayesNet< GUM_SCALAR > & src )
private

read the first line of a file to find column names

References _labelsFromBN_().

Referenced by _labelsFromBN_().

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

◆ _learnParameters_()

template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR > gum::learning::BNLearner< GUM_SCALAR >::_learnParameters_ ( const DAG & dag,
bool takeIntoAccountScore )
private

learns a BN (its parameters) with the structure passed in argument using a single pass estimation (not EM)

Parameters
dagthe structure of the Bayesian network
takeIntoAccountScoreThe 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 prior (like K2 which has a 1-smoothing prior), it is important to also take into account this implicit prior for parameter learning. By default, if a score exists, we will learn parameters by taking into account the prior specified by methods usePriorXXX () + the implicit prior of the score, else we just take into account the prior specified by usePriorXXX ()
Exceptions
MissingVariableInDatabaseif a variable of the BN is not found in the database.
MissingValueInDatabaseif the database contains some missing values

References _learnParameters_().

Referenced by _learnParameters_().

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

◆ _learnParametersWithEM_() [1/2]

template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR > gum::learning::BNLearner< GUM_SCALAR >::_learnParametersWithEM_ ( const BayesNet< GUM_SCALAR > & bn,
bool takeIntoAccountScore )
private

learns a BN (its parameters) with the structure passed in argument using the EM algorithm initialized by the Bayes net passed in argument

Parameters
bnthe Bayesian network used to specify the graphical structure of the returned Bayes net and to initialize its CPTs before running EM. When a CPT is filled exclusively with only zeroes, then this one is initialized by the BNLearner using a specific estimator that does not take into account the missing values in the database
takeIntoAccountScoreThe 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 prior (like K2 which has a 1-smoothing prior), it is important to also take into account this implicit prior for parameter learning. By default, if a score exists, we will learn parameters by taking into account the prior specified by methods usePriorXXX () + the implicit prior of the score, else we just take into account the prior specified by usePriorXXX ()
Exceptions
MissingVariableInDatabaseif a variable of the BN is not found in the database.
Warning
the EM algorithm initializes the parameters of the CPTs using those of the Bayes net passed in argument whenever those are not fully filled with zeroes, else the BNLearner initializes them using an estimator that does not take into account the missing values. If you wish the BNLearner to automatically initialize all the CPTs, use the method in which a DAG is passed in argument rather than a Bayes net.

References _learnParametersWithEM_().

Here is the call graph for this function:

◆ _learnParametersWithEM_() [2/2]

template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR > gum::learning::BNLearner< GUM_SCALAR >::_learnParametersWithEM_ ( const DAG & dag,
bool takeIntoAccountScore )
private

learns a BN (its parameters) with the structure passed in argument using the EM algorithm initialized by the BNLearner

Parameters
dagthe structure of the Bayesian network
takeIntoAccountScoreThe 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 prior (like K2 which has a 1-smoothing prior), it is important to also take into account this implicit prior for parameter learning. By default, if a score exists, we will learn parameters by taking into account the prior specified by methods usePriorXXX () + the implicit prior of the score, else we just take into account the prior specified by usePriorXXX ()
Exceptions
MissingVariableInDatabaseif a variable of the BN is not found in the database.
Warning
the EM algorithm initializes the parameters of the CPTs by running a first estimator that does not take into account missing values. If you wish to initialize them yourself, use the method in which a Bayes net is passed in argument rather than a DAG.

References _learnParametersWithEM_().

Referenced by _learnParametersWithEM_(), and _learnParametersWithEM_().

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

◆ _setPriorWeight_()

INLINE void gum::learning::IBNLearner::_setPriorWeight_ ( double weight)
protectedinherited

sets the prior weight

Definition at line 675 of file IBNLearner_inl.h.

675 {
676 if (weight < 0) { GUM_ERROR(OutOfBounds, "the weight of the prior must be positive") }
677
678 priorWeight_ = weight;
680 }
double priorWeight_
the weight of the prior. It is always written by the useXxxPrior() methods, which read learning....
std::string checkScorePriorCompatibility() const
checks whether the current score and prior are compatible
#define GUM_ERROR(type, msg)
Definition exceptions.h:76

References checkScorePriorCompatibility(), GUM_ERROR, and priorWeight_.

Referenced by useBDeuPrior(), useDirichletPrior(), and useSmoothingPrior().

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

◆ addForbiddenArc() [1/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addForbiddenArc ( const Arc & arc)

References BNLearner(), and addForbiddenArc().

Referenced by addForbiddenArc(), addForbiddenArc(), and addForbiddenArc().

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

◆ addForbiddenArc() [2/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addForbiddenArc ( NodeId tail,
NodeId head )

References BNLearner(), and addForbiddenArc().

Here is the call graph for this function:

◆ addForbiddenArc() [3/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addForbiddenArc ( std::string_view tail,
std::string_view head )

References BNLearner(), and addForbiddenArc().

Here is the call graph for this function:

◆ addMandatoryArc() [1/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addMandatoryArc ( const Arc & arc)

References BNLearner(), and addMandatoryArc().

Referenced by addMandatoryArc(), addMandatoryArc(), and addMandatoryArc().

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

◆ addMandatoryArc() [2/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addMandatoryArc ( NodeId tail,
NodeId head )

References BNLearner(), and addMandatoryArc().

Here is the call graph for this function:

◆ addMandatoryArc() [3/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addMandatoryArc ( std::string_view tail,
std::string_view head )

References BNLearner(), and addMandatoryArc().

Here is the call graph for this function:

◆ addNoChildrenNode() [1/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addNoChildrenNode ( NodeId node)

References BNLearner(), and addNoChildrenNode().

Referenced by addNoChildrenNode(), and addNoChildrenNode().

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

◆ addNoChildrenNode() [2/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addNoChildrenNode ( std::string_view name)

References BNLearner(), and addNoChildrenNode().

Here is the call graph for this function:

◆ addNoParentNode() [1/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addNoParentNode ( NodeId node)

References BNLearner(), and addNoParentNode().

Referenced by addNoParentNode(), and addNoParentNode().

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

◆ addNoParentNode() [2/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addNoParentNode ( std::string_view name)

References BNLearner(), and addNoParentNode().

Here is the call graph for this function:

◆ addPossibleEdge() [1/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addPossibleEdge ( const Edge & edge)

References BNLearner(), and addPossibleEdge().

Referenced by addPossibleEdge(), addPossibleEdge(), and addPossibleEdge().

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

◆ addPossibleEdge() [2/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addPossibleEdge ( NodeId tail,
NodeId head )

References BNLearner(), and addPossibleEdge().

Here is the call graph for this function:

◆ addPossibleEdge() [3/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addPossibleEdge ( std::string_view tail,
std::string_view head )

References BNLearner(), and addPossibleEdge().

Here is the call graph for this function:

◆ allowArcAdditions()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::allowArcAdditions ( bool allow)

References BNLearner(), and allowArcAdditions().

Referenced by allowArcAdditions().

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

◆ allowArcDeletions()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::allowArcDeletions ( bool allow)

References BNLearner(), and allowArcDeletions().

Referenced by allowArcDeletions().

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

◆ allowArcReversals()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::allowArcReversals ( bool allow)

References BNLearner(), and allowArcReversals().

Referenced by allowArcReversals().

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

◆ allowArcTriangleDeletions()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::allowArcTriangleDeletions ( bool allow)

References BNLearner(), and allowArcTriangleDeletions().

Referenced by allowArcTriangleDeletions().

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

◆ checkScorePriorCompatibility()

std::string gum::learning::IBNLearner::checkScorePriorCompatibility ( ) const
inherited

checks whether the current score and prior are compatible

Returns
a non empty string if the prior is somehow compatible with the score.

Definition at line 1300 of file IBNLearner.cpp.

1300 {
1301 if (this->isConstraintBased()) return "";
1302
1303 const auto prior = getPriorType_();
1304
1305 switch (scoreType_) {
1307 case AIC : return ScoreAIC::isPriorCompatible(prior, priorWeight_);
1308
1309 case BD : return ScoreBD::isPriorCompatible(prior, priorWeight_);
1310
1311 case BDeu : return ScoreBDeu::isPriorCompatible(prior, priorWeight_);
1312
1313 case BIC : return ScoreBIC::isPriorCompatible(prior, priorWeight_);
1314
1315 case fNML : return ScorefNML::isPriorCompatible(prior, priorWeight_);
1316
1317 case K2 : return ScoreK2::isPriorCompatible(prior, priorWeight_);
1318
1320
1321 case MDL : return ScoreMDL::isPriorCompatible(prior, priorWeight_);
1322
1323 default : return "IBNLearner does not support yet this score";
1324 }
1325 }
ScoreType
an enumeration enabling to select easily the score we wish to use
Definition IBNLearner.h:110
ScoreType scoreType_
the score selected for learning
PriorType getPriorType_() const
returns the type (as a string) of a given prior
bool isConstraintBased() const
indicate if the selected algorithm is constraint-based
std::string isPriorCompatible() const final
indicates whether the prior is compatible (meaningful) with the score
std::string isPriorCompatible() const final
indicates whether the prior is compatible (meaningful) with the score
std::string isPriorCompatible() const final
indicates whether the prior is compatible (meaningful) with the score
std::string isPriorCompatible() const final
indicates whether the prior is compatible (meaningful) with the score
std::string isPriorCompatible() const final
indicates whether the prior is compatible (meaningful) with the score
std::string isPriorCompatible() const final
indicates whether the prior is compatible (meaningful) with the score
std::string isPriorCompatible() const final
indicates whether the prior is compatible (meaningful) with the score

References getPriorType_(), isConstraintBased(), gum::learning::ScoreAIC::isPriorCompatible(), gum::learning::ScoreBD::isPriorCompatible(), gum::learning::ScoreBDeu::isPriorCompatible(), gum::learning::ScoreBIC::isPriorCompatible(), gum::learning::ScorefNML::isPriorCompatible(), gum::learning::ScoreK2::isPriorCompatible(), gum::learning::ScoreLog2Likelihood::isPriorCompatible(), priorWeight_, and scoreType_.

Referenced by _setPriorWeight_(), useBDeuPrior(), useDirichletPrior(), useNoPrior(), useScoreAIC(), useScoreBD(), useScoreBDeu(), useScoreBIC(), useScorefNML(), useScoreK2(), useScoreLog2Likelihood(), useScoreMDL(), and useSmoothingPrior().

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

◆ chi2() [1/2]

std::pair< double, double > gum::learning::IBNLearner::chi2 ( NodeId id1,
NodeId id2,
const std::vector< NodeId > & knowing = {} )
inherited

Return the <statistic,pvalue> pair for chi2 test in the database.

Parameters
id1first variable
id2second variable
knowinglist of observed variables
Returns
a std::pair<double,double>

Definition at line 1368 of file IBNLearner.cpp.

1368 {
1369 createPrior_();
1370 gum::learning::IndepTestChi2 chi2score(scoreDatabase_.parser(), *prior_, databaseRanges());
1371
1372 return chi2score.statistics(id1, id2, knowing);
1373 }
DBRowGeneratorParser & parser()
returns the parser for the database
virtual void createPrior_()=0
create the prior used for learning
const std::vector< std::pair< std::size_t, std::size_t > > & databaseRanges() const
returns the current database rows' ranges used for learning
Database scoreDatabase_
the database to be used by the scores and parameter estimators
Prior * prior_
the prior used

References createPrior_(), databaseRanges(), gum::learning::IBNLearner::Database::parser(), prior_, scoreDatabase_, and gum::learning::IndepTestChi2::statistics().

Referenced by chi2().

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

◆ chi2() [2/2]

std::pair< double, double > gum::learning::IBNLearner::chi2 ( std::string_view name1,
std::string_view name2,
const std::vector< std::string > & knowing = {} )
inherited

Return the <statistic,pvalue> pair for the BNLearner.

Parameters
id1first variable
id2second variable
knowinglist of observed variables
Returns
a std::pair<double,double>

Definition at line 1375 of file IBNLearner.cpp.

1377 {
1378 std::vector< NodeId > knowingIds;
1379 std::transform(knowing.begin(),
1380 knowing.end(),
1381 std::back_inserter(knowingIds),
1382 [this](const std::string& c) { return this->idFromName(c); });
1383 return chi2(idFromName(name1), idFromName(name2), knowingIds);
1384 }
std::pair< double, double > chi2(NodeId id1, NodeId id2, const std::vector< NodeId > &knowing={})
Return the <statistic,pvalue> pair for chi2 test in the database.
NodeId idFromName(std::string_view var_name) const
returns the node id corresponding to a variable name

References chi2(), and idFromName().

Here is the call graph for this function:

◆ clearDatabaseRanges()

INLINE void gum::learning::IBNLearner::clearDatabaseRanges ( )
inherited

reset the ranges to the one range corresponding to the whole database

Definition at line 775 of file IBNLearner_inl.h.

775{ ranges_.clear(); }
std::vector< std::pair< std::size_t, std::size_t > > ranges_
the set of rows' ranges within the database in which learning is done

References ranges_.

◆ copyState()

template<GUM_Numeric GUM_SCALAR>
void gum::learning::BNLearner< GUM_SCALAR >::copyState ( const BNLearner< GUM_SCALAR > & learner)

copy the states of the BNLearner

Warning
except the database ! just the configurations of the learner

References BNLearner(), and copyState().

Referenced by copyState().

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

◆ correctedMutualInformation() [1/2]

double gum::learning::IBNLearner::correctedMutualInformation ( NodeId id1,
NodeId id2,
const std::vector< NodeId > & knowing = {} )
inherited

Return the mutual information of id1 and id2 in the base, conditioned by knowing for the BNLearner.

Warning
This function returns the mutual information corrected using defined correction (useNML, useMDL) and prior
Parameters
id1nodeId
id2nodeId
knowingan optional vector of conditioning NodeIds
Returns
a double

Definition at line 1433 of file IBNLearner.cpp.

1435 {
1436 createPrior_();
1437 gum::learning::CorrectedMutualInformation cmi(scoreDatabase_.parser(),
1438 *prior_,
1439 databaseRanges());
1440
1441 switch (kmodeMiic_) {
1443 case MDL : cmi.useMDL(); break;
1444
1445 case NML : cmi.useNML(); break;
1446
1447 case NoCorr : cmi.useNoCorr(); break;
1448
1449 default :
1450 GUM_ERROR(NotImplementedYet,
1451 "The BNLearner's corrected mutual information class does "
1452 << "not implement yet this correction : " << int(kmodeMiic_))
1453 }
1454 if (knowing.size() == (Size)0) return cmi.score(id1, id2) / scoreDatabase_.weight();
1455 else return cmi.score(id1, id2, knowing) / scoreDatabase_.weight();
1456 }
KModeTypes
the description type for the complexity correction
double weight(const std::size_t i) const
returns the weight of the ith record
CorrectedMutualInformation::KModeTypes kmodeMiic_
the penalty used in MIIC
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74

References createPrior_(), databaseRanges(), GUM_ERROR, kmodeMiic_, gum::learning::IBNLearner::Database::parser(), prior_, gum::learning::CorrectedMutualInformation::score(), scoreDatabase_, gum::learning::CorrectedMutualInformation::useMDL(), gum::learning::CorrectedMutualInformation::useNML(), gum::learning::CorrectedMutualInformation::useNoCorr(), and gum::learning::IBNLearner::Database::weight().

Referenced by correctedMutualInformation().

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

◆ correctedMutualInformation() [2/2]

double gum::learning::IBNLearner::correctedMutualInformation ( std::string_view var1,
std::string_view var2,
const std::vector< std::string > & knowing = {} )
inherited

Return the mutual information of var1 and var2 in the base, conditioned by knowing for the BNLearner.

Warning
This function returns the mutual information corrected using defined correction (useNML, useMDL) and prior
This function returns the bare mutual information (without prior or correction)
Parameters
var1name of a row
var2name of a row
knowingan optional vector of conditioning rows
Returns
a double

Definition at line 1458 of file IBNLearner.cpp.

1460 {
1461 std::vector< NodeId > knowingIds;
1462
1463 auto mapper = [this](const std::string& c) { return this->idFromName(c); };
1464
1465 std::transform(knowing.begin(), knowing.end(), std::back_inserter(knowingIds), mapper);
1466
1467 return correctedMutualInformation(this->idFromName(var1), this->idFromName(var2), knowingIds);
1468 }
double correctedMutualInformation(NodeId id1, NodeId id2, const std::vector< NodeId > &knowing={})
Return the mutual information of id1 and id2 in the base, conditioned by knowing for the BNLearner.

References correctedMutualInformation(), and idFromName().

Here is the call graph for this function:

◆ createCorrectedMutualInformation_()

void gum::learning::IBNLearner::createCorrectedMutualInformation_ ( )
protectedinherited

create the Corrected Mutual Information instance for Miic

Definition at line 996 of file IBNLearner.cpp.

996 {
997 if (mutualInfo_ != nullptr) delete mutualInfo_;
998
1000 *noPrior_,
1001 ranges_,
1003 switch (kmodeMiic_) {
1005 case MDL : mutualInfo_->useMDL(); break;
1006 case NML : mutualInfo_->useNML(); break;
1007 case NoCorr : mutualInfo_->useNoCorr(); break;
1008 default :
1009 GUM_ERROR(NotImplementedYet,
1010 "The BNLearner's corrected mutual information class does "
1011 << "not implement yet this correction : " << int(kmodeMiic_))
1012 }
1013 }
void useNML()
use the kNML penalty function
CorrectedMutualInformation(const DBRowGeneratorParser &parser, const Prior &prior, const std::vector< std::pair< std::size_t, std::size_t > > &ranges, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
void useNoCorr()
use no correction/penalty function
void useMDL()
use the MDL penalty function
const Bijection< NodeId, std::size_t > & nodeId2Columns() const
returns the mapping between node ids and their columns in the database
CorrectedMutualInformation * mutualInfo_
the selected correction for miic

References gum::learning::CorrectedMutualInformation::CorrectedMutualInformation(), GUM_ERROR, kmodeMiic_, mutualInfo_, gum::learning::IBNLearner::Database::nodeId2Columns(), noPrior_, gum::learning::IBNLearner::Database::parser(), ranges_, scoreDatabase_, gum::learning::CorrectedMutualInformation::useMDL(), gum::learning::CorrectedMutualInformation::useNML(), and gum::learning::CorrectedMutualInformation::useNoCorr().

Referenced by createPrior_(), and prepareMiic_().

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

◆ createParamEstimator_()

ParamEstimator * gum::learning::IBNLearner::createParamEstimator_ ( const DBRowGeneratorParser & parser,
bool take_into_account_score = true )
protectedinherited

create the parameter estimator used for learning

Definition at line 589 of file IBNLearner.cpp.

590 {
591 ParamEstimator* param_estimator = nullptr;
592
593 // create the new estimator
594 switch (paramEstimatorType_) {
596 if (take_into_account_score && (score_ != nullptr)) {
597 param_estimator = new ParamEstimatorML(parser,
598 *prior_,
600 ranges_,
602 } else {
603 param_estimator = new ParamEstimatorML(parser,
604 *prior_,
605 *noPrior_,
606 ranges_,
608 }
609
610 break;
611
612 default :
613 GUM_ERROR(OperationNotAllowed,
614 "IBNLearner does not support " << "yet this parameter estimator")
615 }
616
617 // assign the number of threads
618 param_estimator->setNumberOfThreads(
620
621 // assign the set of ranges
622 param_estimator->setRanges(ranges_);
623
624 return param_estimator;
625 }
ParamEstimatorType paramEstimatorType_
the type of the parameter estimator
Score * score_
the score used
ParamEstimatorML(const DBRowGeneratorParser &parser, const Prior &external_prior, const Prior &_score_internal_prior, const std::vector< std::pair< std::size_t, std::size_t > > &ranges, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
virtual const Prior & internalPrior() const =0
returns the internal prior of the score
virtual Size getNumberOfThreads() const =0
returns the current max number of threads of the scheduler
virtual bool isGumNumberOfThreadsOverriden() const =0
indicates whether the user set herself the number of threads

References gum::learning::ParamEstimatorML::ParamEstimatorML(), gum::ThreadNumberManager::getNumberOfThreads(), GUM_ERROR, gum::learning::Score::internalPrior(), gum::ThreadNumberManager::isGumNumberOfThreadsOverriden(), ML, gum::learning::IBNLearner::Database::nodeId2Columns(), noPrior_, paramEstimatorType_, prior_, ranges_, score_, scoreDatabase_, gum::learning::ParamEstimator::setNumberOfThreads(), and gum::learning::ParamEstimator::setRanges().

Referenced by createPrior_().

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

◆ createPrior_()

template<GUM_Numeric GUM_SCALAR>
void gum::learning::BNLearner< GUM_SCALAR >::createPrior_ ( )
overrideprotectedvirtual

create the prior used for learning

Implements gum::learning::IBNLearner.

References createPrior_().

Referenced by createPrior_().

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

◆ createScore_()

void gum::learning::IBNLearner::createScore_ ( )
protectedinherited

create the score used for learning

Definition at line 516 of file IBNLearner.cpp.

516 {
517 // first, save the old score, to be delete if everything is ok
518 Score* old_score = score_;
519
520 // create the new scoring function
521 switch (scoreType_) {
522 case ScoreType::AIC :
524 *prior_,
525 ranges_,
527 break;
528
529 case ScoreType::BD :
531 *prior_,
532 ranges_,
534 break;
535
536 case ScoreType::BDeu :
538 *prior_,
539 ranges_,
541 break;
542
543 case ScoreType::BIC :
545 *prior_,
546 ranges_,
548 break;
549
550 case ScoreType::fNML :
552 *prior_,
553 ranges_,
555 break;
556
557 case ScoreType::K2 :
559 *prior_,
560 ranges_,
562 break;
563
566 *prior_,
567 ranges_,
569 break;
570
571 case ScoreType::MDL :
573 *prior_,
574 ranges_,
576 break;
577
578 default : GUM_ERROR(OperationNotAllowed, "IBNLearner does not support yet this score")
579 }
580
581 // remove the old score, if any
582 if (old_score != nullptr) delete old_score;
583
584 // assign the number of threads
586 : 0);
587 }
ScoreAIC(const DBRowGeneratorParser &parser, const Prior &prior, const std::vector< std::pair< std::size_t, std::size_t > > &ranges, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
ScoreBD(const DBRowGeneratorParser &parser, const Prior &prior, const std::vector< std::pair< std::size_t, std::size_t > > &ranges, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
ScoreBDeu(const DBRowGeneratorParser &parser, const Prior &prior, const std::vector< std::pair< std::size_t, std::size_t > > &ranges, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
ScoreBIC(const DBRowGeneratorParser &parser, const Prior &prior, const std::vector< std::pair< std::size_t, std::size_t > > &ranges, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
ScoreK2(const DBRowGeneratorParser &parser, const Prior &prior, const std::vector< std::pair< std::size_t, std::size_t > > &ranges, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
ScoreLog2Likelihood(const DBRowGeneratorParser &parser, const Prior &prior, const std::vector< std::pair< std::size_t, std::size_t > > &ranges, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
void setNumberOfThreads(Size nb) override
sets the number max of threads that can be used
ScorefNML(const DBRowGeneratorParser &parser, const Prior &prior, const std::vector< std::pair< std::size_t, std::size_t > > &ranges, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
ScoreBIC ScoreMDL
Definition scoreMDL.h:67

References gum::learning::ScoreAIC::ScoreAIC(), gum::learning::ScoreBD::ScoreBD(), gum::learning::ScoreBDeu::ScoreBDeu(), gum::learning::ScoreBIC::ScoreBIC(), gum::learning::ScorefNML::ScorefNML(), gum::learning::ScoreK2::ScoreK2(), gum::learning::ScoreLog2Likelihood::ScoreLog2Likelihood(), AIC, BD, BDeu, BIC, fNML, gum::ThreadNumberManager::getNumberOfThreads(), GUM_ERROR, gum::ThreadNumberManager::isGumNumberOfThreadsOverriden(), K2, LOG2LIKELIHOOD, MDL, gum::learning::IBNLearner::Database::nodeId2Columns(), gum::learning::IBNLearner::Database::parser(), prior_, ranges_, score_, scoreDatabase_, scoreType_, and gum::learning::Score::setNumberOfThreads().

Referenced by createPrior_(), learnDAG(), and score().

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

◆ currentTime()

INLINE double gum::learning::IBNLearner::currentTime ( ) const
overridevirtualinherited

get the current running time in second (double)

Implements gum::IApproximationSchemeConfiguration.

Definition at line 936 of file IBNLearner_inl.h.

936 {
937 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->currentTime();
938 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
939 }
double currentTime() const override
Returns the current running time in second.
const ApproximationScheme * currentAlgorithm_

References currentAlgorithm_, gum::ApproximationScheme::currentTime(), and GUM_ERROR.

Referenced by createPrior_().

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

◆ database()

INLINE const DatabaseTable & gum::learning::IBNLearner::database ( ) const
inherited

returns the database used by the BNLearner

Definition at line 778 of file IBNLearner_inl.h.

778 {
780 }
const DatabaseTable & databaseTable() const
returns the internal database table

References gum::learning::IBNLearner::Database::databaseTable(), and scoreDatabase_.

Referenced by readFile_().

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

◆ databaseRanges()

INLINE const std::vector< std::pair< std::size_t, std::size_t > > & gum::learning::IBNLearner::databaseRanges ( ) const
inherited

returns the current database rows' ranges used for learning

Returns
The method returns a vector of pairs [Xi,Yi) of indices of rows in the database. The learning is performed on these set of rows.
Warning
an empty set of ranges means the whole database.

Definition at line 770 of file IBNLearner_inl.h.

770 {
771 return ranges_;
772 }

References ranges_.

Referenced by chi2(), correctedMutualInformation(), G2(), logLikelihood(), mutualInformation(), and rawPseudoCount().

Here is the caller graph for this function:

◆ databaseWeight()

INLINE double gum::learning::IBNLearner::databaseWeight ( ) const
inherited

returns the weight of the whole database

Definition at line 162 of file IBNLearner_inl.h.

162{ return scoreDatabase_.weight(); }

References scoreDatabase_, and gum::learning::IBNLearner::Database::weight().

Here is the call graph for this function:

◆ disableEpsilon()

INLINE void gum::learning::IBNLearner::disableEpsilon ( )
overridevirtualinherited

Disable stopping criterion on epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 843 of file IBNLearner_inl.h.

843 {
848 }
void disableEpsilon() override
Disable stopping criterion on epsilon.
K2 algoK2_
the K2 algorithm
DAG2BNLearner dag2BN_
the parametric EM
GreedyHillClimbing greedyHillClimbing_
the greedy hill climbing algorithm
LocalSearchWithTabuList localSearchWithTabuList_
the local search with tabu list algorithm
ApproximationScheme & approximationScheme()
returns the approximation policy of the learning algorithm

References algoK2_, gum::learning::K2::approximationScheme(), dag2BN_, gum::ApproximationScheme::disableEpsilon(), greedyHillClimbing_, and localSearchWithTabuList_.

Referenced by createPrior_().

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

◆ disableMaxIter()

INLINE void gum::learning::IBNLearner::disableMaxIter ( )
overridevirtualinherited

Disable stopping criterion on max iterations.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 905 of file IBNLearner_inl.h.

905 {
910 }
void disableMaxIter() override
Disable stopping criterion on max iterations.

References algoK2_, gum::learning::K2::approximationScheme(), dag2BN_, gum::ApproximationScheme::disableMaxIter(), greedyHillClimbing_, and localSearchWithTabuList_.

Referenced by createPrior_().

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

◆ disableMaxTime()

INLINE void gum::learning::IBNLearner::disableMaxTime ( )
overridevirtualinherited

Disable stopping criterion on timeout.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 941 of file IBNLearner_inl.h.

References algoK2_, gum::learning::K2::approximationScheme(), dag2BN_, gum::ApproximationScheme::disableMaxTime(), greedyHillClimbing_, and localSearchWithTabuList_.

Referenced by createPrior_().

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

◆ disableMinEpsilonRate()

INLINE void gum::learning::IBNLearner::disableMinEpsilonRate ( )
overridevirtualinherited

Disable stopping criterion on epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 874 of file IBNLearner_inl.h.

References algoK2_, gum::learning::K2::approximationScheme(), dag2BN_, gum::ApproximationScheme::disableMinEpsilonRate(), greedyHillClimbing_, and localSearchWithTabuList_.

Referenced by createPrior_().

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

◆ distributeProgress()

INLINE void gum::learning::IBNLearner::distributeProgress ( const ApproximationScheme * approximationScheme,
Size pourcent,
double error,
double time )
inherited

{@ /// distribute signals

Definition at line 817 of file IBNLearner_inl.h.

820 {
821 setCurrentApproximationScheme(approximationScheme);
822 if (onProgress.hasListener()) GUM_EMIT3(onProgress, pourcent, error, time);
823 }
Signaler< Size, double, double > onProgress
Progression, error and time.
void setCurrentApproximationScheme(const ApproximationScheme *approximationScheme)
{@ /// distribute signals
#define GUM_EMIT3(signal, arg1, arg2, arg3)
Definition signaler.h:291

References GUM_EMIT3, gum::__sig__::BasicSignaler< Args... >::hasListener(), gum::IApproximationSchemeConfiguration::onProgress, and setCurrentApproximationScheme().

Referenced by createPrior_(), and gum::learning::BNLearnerListener::whenProgress().

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

◆ distributeStop()

INLINE void gum::learning::IBNLearner::distributeStop ( const ApproximationScheme * approximationScheme,
std::string_view message )
inherited

distribute signals

Definition at line 825 of file IBNLearner_inl.h.

826 {
827 setCurrentApproximationScheme(approximationScheme);
828 if (onStop.hasListener()) GUM_EMIT1(onStop, message);
829 }
Signaler< std::string_view > onStop
Criteria messageApproximationScheme.
#define GUM_EMIT1(signal, arg1)
Definition signaler.h:289

References GUM_EMIT1, gum::__sig__::BasicSignaler< Args... >::hasListener(), gum::IApproximationSchemeConfiguration::onStop, and setCurrentApproximationScheme().

Referenced by createPrior_(), and gum::learning::BNLearnerListener::whenStop().

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

◆ domainSize() [1/2]

INLINE Size gum::learning::IBNLearner::domainSize ( NodeId var) const
inherited

learn a structure from a file (must have read the db before)

Definition at line 761 of file IBNLearner_inl.h.

761{ return scoreDatabase_.domainSizes()[var]; }
const std::vector< std::size_t > & domainSizes() const
returns the domain sizes of the variables

References gum::learning::IBNLearner::Database::domainSizes(), and scoreDatabase_.

Here is the call graph for this function:

◆ domainSize() [2/2]

INLINE Size gum::learning::IBNLearner::domainSize ( std::string_view var) const
inherited

learn a structure from a file (must have read the db before)

Definition at line 764 of file IBNLearner_inl.h.

764 {
766 }

References gum::learning::IBNLearner::Database::domainSizes(), idFromName(), and scoreDatabase_.

Here is the call graph for this function:

◆ domainSizes()

INLINE const std::vector< std::size_t > & gum::learning::IBNLearner::domainSizes ( ) const
inherited

returns the domain sizes of the variables in the database

Definition at line 756 of file IBNLearner_inl.h.

756 {
758 }

References gum::learning::IBNLearner::Database::domainSizes(), and scoreDatabase_.

Here is the call graph for this function:

◆ EM()

INLINE EMApproximationScheme & gum::learning::IBNLearner::EM ( )
inherited

returns the EM parameter learning approximation scheme if EM is enabled

returns the EM parameter learning approximation scheme

Returns
returns the EM parameter learning approximation scheme if EM is enabled, else if raises a NotFound exception. The scheme can then be subsequently used to fine-tune the EM algorithm, e.g., by setting its max time or max number of iterations.
Exceptions
NotFoundis raised if EM() is called while the EM algorithm has not been enabled by useEM(), useEMWithDiffCriterion() or useEMWithRateCriterion().

Definition at line 467 of file IBNLearner_inl.h.

467 {
468 if (useEM_) return dag2BN_;
469 else GUM_ERROR(NotFound, "EM is currently forbidden. Please enable it with useEM()")
470 }
bool useEM_
a Boolean indicating whether we should use EM for parameter learning or not

References dag2BN_, GUM_ERROR, and useEM_.

◆ EMCurrentTime()

INLINE double gum::learning::IBNLearner::EMCurrentTime ( ) const
inherited

get the current running time in second (double)

Definition at line 1038 of file IBNLearner_inl.h.

1038{ return dag2BN_.currentTime(); }

References gum::ApproximationScheme::currentTime(), and dag2BN_.

Referenced by createPrior_().

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

◆ EMdisableEpsilon()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::EMdisableEpsilon ( )

Disable the min log-likelihood diff stopping criterion.

References BNLearner(), and EMdisableEpsilon().

Referenced by EMdisableEpsilon().

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

◆ EMdisableMaxIter()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::EMdisableMaxIter ( )

Disable stopping criterion on max iterations.

References BNLearner(), and EMdisableMaxIter().

Referenced by EMdisableMaxIter().

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

◆ EMdisableMaxTime()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::EMdisableMaxTime ( )

Disable EM's timeout stopping criterion.

References BNLearner(), and EMdisableMaxTime().

Referenced by EMdisableMaxTime().

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

◆ EMdisableMinEpsilonRate()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::EMdisableMinEpsilonRate ( )

Disable the log-likelihood evolution rate stopping criterion.

References BNLearner(), and EMdisableMinEpsilonRate().

Referenced by EMdisableMinEpsilonRate().

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

◆ EMenableEpsilon()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::EMenableEpsilon ( )

Enable the log-likelihood min diff stopping criterion in EM.

Warning
setting this stopping criterion disables the min rate criterion (if it was enabled)

References BNLearner(), and EMenableEpsilon().

Referenced by EMenableEpsilon().

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

◆ EMenableMaxIter()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::EMenableMaxIter ( )

Enable stopping criterion on max iterations.

References BNLearner(), and EMenableMaxIter().

Referenced by EMenableMaxIter().

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

◆ EMenableMaxTime()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::EMenableMaxTime ( )

enable EM's timeout stopping criterion

References BNLearner(), and EMenableMaxTime().

Referenced by EMenableMaxTime().

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

◆ EMenableMinEpsilonRate()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::EMenableMinEpsilonRate ( )

Enable the log-likelihood evolution rate stopping criterion.

Warning
setting this stopping criterion disables the min diff criterion (if it was enabled)

References BNLearner(), and EMenableMinEpsilonRate().

Referenced by EMenableMinEpsilonRate().

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

◆ EMEpsilon()

INLINE double gum::learning::IBNLearner::EMEpsilon ( ) const
inherited

Get the value of EM's min diff epsilon.

Get the value of EM's min diff epsilon

Warning
Note that this value is not taken into account unless the min diff criterion is enabled

Definition at line 1004 of file IBNLearner_inl.h.

1004{ return dag2BN_.epsilon(); }
double epsilon() const override
Returns the value of epsilon.

References dag2BN_, and gum::ApproximationScheme::epsilon().

Referenced by createPrior_().

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

◆ EMHistory()

INLINE const std::vector< double > & gum::learning::IBNLearner::EMHistory ( ) const
inherited

returns the history of the last EM execution

Warning
to activate the history recording, EM's verbosity must be set to true

Definition at line 1061 of file IBNLearner_inl.h.

1061{ return dag2BN_.history(); }
const std::vector< double > & history() const override
Returns the scheme history.

References dag2BN_, and gum::ApproximationScheme::history().

Referenced by createPrior_().

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

◆ EMisEnabledEpsilon()

INLINE bool gum::learning::IBNLearner::EMisEnabledEpsilon ( ) const
inherited

return true if EM's stopping criterion is the log-likelihood min diff

Definition at line 1010 of file IBNLearner_inl.h.

1010{ return dag2BN_.isEnabledEpsilon(); }
bool isEnabledEpsilon() const override
Returns true if stopping criterion on epsilon is enabled, false otherwise.

References dag2BN_, and gum::ApproximationScheme::isEnabledEpsilon().

Referenced by createPrior_().

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

◆ EMisEnabledMaxIter()

INLINE bool gum::learning::IBNLearner::EMisEnabledMaxIter ( ) const
inherited
Returns
true if stopping criterion on max iterations is enabled, false otherwise

Definition at line 1032 of file IBNLearner_inl.h.

1032{ return dag2BN_.isEnabledMaxIter(); }
bool isEnabledMaxIter() const override
Returns true if stopping criterion on max iterations is enabled, false otherwise.

References dag2BN_, and gum::ApproximationScheme::isEnabledMaxIter().

Referenced by createPrior_().

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

◆ EMisEnabledMaxTime()

INLINE bool gum::learning::IBNLearner::EMisEnabledMaxTime ( ) const
inherited
Returns
true if stopping criterion on timeout is enabled, false otherwise

Definition at line 1044 of file IBNLearner_inl.h.

1044{ return dag2BN_.isEnabledMaxTime(); }
bool isEnabledMaxTime() const override
Returns true if stopping criterion on timeout is enabled, false otherwise.

References dag2BN_, and gum::ApproximationScheme::isEnabledMaxTime().

Referenced by createPrior_().

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

◆ EMisEnabledMinEpsilonRate()

INLINE bool gum::learning::IBNLearner::EMisEnabledMinEpsilonRate ( ) const
inherited
Returns
true if EM's stopping criterion is the log-likelihood evolution rate

Definition at line 1020 of file IBNLearner_inl.h.

1020 {
1022 }
bool isEnabledMinEpsilonRate() const override
Returns true if stopping criterion on epsilon rate is enabled, false otherwise.

References dag2BN_, and gum::ApproximationScheme::isEnabledMinEpsilonRate().

Referenced by createPrior_().

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

◆ EMMaxIter()

INLINE Size gum::learning::IBNLearner::EMMaxIter ( ) const
inherited

return the max number of iterations criterion

Warning
Note that this value is not taken into account unless the max iter criterion is enabled

Definition at line 1026 of file IBNLearner_inl.h.

1026{ return dag2BN_.maxIter(); }
Size maxIter() const override
Returns the criterion on number of iterations.

References dag2BN_, and gum::ApproximationScheme::maxIter().

Referenced by createPrior_().

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

◆ EMMaxTime()

INLINE double gum::learning::IBNLearner::EMMaxTime ( ) const
inherited

@brief returns EM's timeout (in milliseconds)

Warning
Note that this value is not taken into account unless the max time criterion is enabled

Definition at line 1036 of file IBNLearner_inl.h.

1036{ return dag2BN_.maxTime(); }
double maxTime() const override
Returns the timeout (in seconds).

References dag2BN_, and gum::ApproximationScheme::maxTime().

Referenced by createPrior_().

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

◆ EMMinEpsilonRate()

INLINE double gum::learning::IBNLearner::EMMinEpsilonRate ( ) const
inherited

Get the value of the minimal log-likelihood evolution rate of EM.

Warning
Note that this value is not taken into account unless the min rate criterion is enabled

Definition at line 1014 of file IBNLearner_inl.h.

1014{ return dag2BN_.minEpsilonRate(); }
double minEpsilonRate() const override
Returns the value of the minimal epsilon rate.

References dag2BN_, and gum::ApproximationScheme::minEpsilonRate().

Referenced by createPrior_().

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

◆ EMnbrIterations()

INLINE Size gum::learning::IBNLearner::EMnbrIterations ( ) const
inherited

returns the number of iterations performed by the last EM execution

Definition at line 1059 of file IBNLearner_inl.h.

1059{ return dag2BN_.nbrIterations(); }
Size nbrIterations() const override
Returns the number of iterations.

References dag2BN_, and gum::ApproximationScheme::nbrIterations().

Referenced by createPrior_().

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

◆ EMPeriodSize()

template<GUM_Numeric GUM_SCALAR>
INLINE Size gum::learning::IBNLearner::EMPeriodSize ( ) const

Definition at line 1611 of file IBNLearner_inl.h.

1048{ return dag2BN_.periodSize(); }

Referenced by EMsetPeriodSize().

Here is the caller graph for this function:

◆ EMsetEpsilon()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::EMsetEpsilon ( const double eps)

sets the stopping criterion of EM as being the minimal difference between two consecutive log-likelihoods

Parameters
epsthe log-likelihood difference below which EM stops its iterations
Warning
setting this stopping criterion disables the min rate criterion (if it was enabled)
Exceptions
OutOfBoundsif eps <= 0

References BNLearner(), and EMsetEpsilon().

Referenced by EMsetEpsilon().

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

◆ EMsetMaxIter()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::EMsetMaxIter ( const Size max)

add a max iteration stopping criterion

Parameters
maxthe max number of iterations that EM is allowed to perform
Exceptions
OutOfBoundsif max<=1

References BNLearner(), and EMsetMaxIter().

Referenced by EMsetMaxIter().

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

◆ EMsetMaxTime()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::EMsetMaxTime ( const double timeout)

add a stopping criterion on timeout

Parameters
timeoutthe timeout in milliseconds
Exceptions
OutOfBoundsif timeout<=0.0

References BNLearner(), and EMsetMaxTime().

Referenced by EMsetMaxTime().

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

◆ EMsetMinEpsilonRate()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::EMsetMinEpsilonRate ( const double rate)

sets the stopping criterion of EM as being the minimal log-likelihood's evolution rate

Parameters
ratethe log-likelihood evolution rate below which EM stops its iterations
Warning
setting this stopping criterion disables the min diff criterion (if it was enabled)
Exceptions
OutOfBoundsif rate<=0

References BNLearner(), and EMsetMinEpsilonRate().

Referenced by EMsetMinEpsilonRate().

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

◆ EMsetPeriodSize()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::EMsetPeriodSize ( const Size p)

how many samples between 2 stoppings isEnabled

Exceptions
OutOfBoundsif p<1

References BNLearner(), gum::learning::IBNLearner::IBNLearner(), EMPeriodSize(), and EMsetPeriodSize().

Referenced by EMsetPeriodSize().

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

◆ EMsetVerbosity()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::EMsetVerbosity ( const bool v)

sets or unsets EM's verbosity

References BNLearner(), and EMsetVerbosity().

Referenced by EMsetVerbosity().

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

◆ EMState()

INLINE IApproximationSchemeConfiguration::ApproximationSchemeSTATE gum::learning::IBNLearner::EMState ( ) const
inherited

returns the state of the last EM algorithm executed

Definition at line 473 of file IBNLearner_inl.h.

References dag2BN_, gum::ApproximationScheme::stateApproximationScheme(), gum::IApproximationSchemeConfiguration::Undefined, and useEM_.

Here is the call graph for this function:

◆ EMStateApproximationScheme()

INLINE IApproximationSchemeConfiguration::ApproximationSchemeSTATE gum::learning::IBNLearner::EMStateApproximationScheme ( ) const
inherited

get the current state of EM

Definition at line 1055 of file IBNLearner_inl.h.

1055 {
1057 }

References dag2BN_, and gum::ApproximationScheme::stateApproximationScheme().

Referenced by createPrior_().

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

◆ EMStateMessage()

INLINE std::string gum::learning::IBNLearner::EMStateMessage ( ) const
inherited

returns the state of the EM algorithm

Definition at line 479 of file IBNLearner_inl.h.

479 {
481 else return "EM is currently forbidden. Please enable it with useEM()";
482 }
std::string messageApproximationScheme() const
Returns the approximation scheme message.

References dag2BN_, gum::IApproximationSchemeConfiguration::messageApproximationScheme(), and useEM_.

Here is the call graph for this function:

◆ EMVerbosity()

INLINE bool gum::learning::IBNLearner::EMVerbosity ( ) const
inherited

returns the EM's verbosity status

Definition at line 1052 of file IBNLearner_inl.h.

1052{ return dag2BN_.verbosity(); }
bool verbosity() const override
Returns true if verbosity is enabled.

References dag2BN_, and gum::ApproximationScheme::verbosity().

Referenced by createPrior_().

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

◆ enableEpsilon()

INLINE void gum::learning::IBNLearner::enableEpsilon ( )
overridevirtualinherited

Enable stopping criterion on epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 850 of file IBNLearner_inl.h.

850 {
855 }
void enableEpsilon() override
Enable stopping criterion on epsilon.

References algoK2_, gum::learning::K2::approximationScheme(), dag2BN_, gum::ApproximationScheme::enableEpsilon(), greedyHillClimbing_, and localSearchWithTabuList_.

Referenced by createPrior_().

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

◆ enableMaxIter()

INLINE void gum::learning::IBNLearner::enableMaxIter ( )
overridevirtualinherited

Enable stopping criterion on max iterations.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 912 of file IBNLearner_inl.h.

912 {
917 }
void enableMaxIter() override
Enable stopping criterion on max iterations.

References algoK2_, gum::learning::K2::approximationScheme(), dag2BN_, gum::ApproximationScheme::enableMaxIter(), greedyHillClimbing_, and localSearchWithTabuList_.

Referenced by createPrior_().

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

◆ enableMaxTime()

INLINE void gum::learning::IBNLearner::enableMaxTime ( )
overridevirtualinherited

stopping criterion on timeout If the criterion was disabled it will be enabled

Exceptions
OutOfBoundsif timeout<=0.0 timeout is time in second (double).

Implements gum::IApproximationSchemeConfiguration.

Definition at line 948 of file IBNLearner_inl.h.

References algoK2_, gum::learning::K2::approximationScheme(), dag2BN_, gum::ApproximationScheme::enableMaxTime(), greedyHillClimbing_, and localSearchWithTabuList_.

Referenced by createPrior_().

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

◆ enableMinEpsilonRate()

INLINE void gum::learning::IBNLearner::enableMinEpsilonRate ( )
overridevirtualinherited

Enable stopping criterion on epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 881 of file IBNLearner_inl.h.

References algoK2_, gum::learning::K2::approximationScheme(), dag2BN_, gum::ApproximationScheme::enableMinEpsilonRate(), greedyHillClimbing_, and localSearchWithTabuList_.

Referenced by createPrior_().

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

◆ epsilon()

INLINE double gum::learning::IBNLearner::epsilon ( ) const
overridevirtualinherited

Get the value of epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 838 of file IBNLearner_inl.h.

838 {
839 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->epsilon();
840 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
841 }

References currentAlgorithm_, gum::ApproximationScheme::epsilon(), and GUM_ERROR.

Referenced by createPrior_(), gum::learning::BNLearner< GUM_SCALAR >::useEM(), gum::learning::BNLearner< GUM_SCALAR >::useEM(), useEM(), useEM(), gum::learning::BNLearner< GUM_SCALAR >::useEMWithDiffCriterion(), gum::learning::BNLearner< GUM_SCALAR >::useEMWithDiffCriterion(), useEMWithDiffCriterion(), useEMWithDiffCriterion(), gum::learning::BNLearner< GUM_SCALAR >::useEMWithRateCriterion(), gum::learning::BNLearner< GUM_SCALAR >::useEMWithRateCriterion(), useEMWithRateCriterion(), and useEMWithRateCriterion().

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

◆ eraseForbiddenArc() [1/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::eraseForbiddenArc ( const Arc & arc)

References BNLearner(), and eraseForbiddenArc().

Referenced by eraseForbiddenArc(), eraseForbiddenArc(), and eraseForbiddenArc().

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

◆ eraseForbiddenArc() [2/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::eraseForbiddenArc ( NodeId tail,
NodeId head )

References BNLearner(), and eraseForbiddenArc().

Here is the call graph for this function:

◆ eraseForbiddenArc() [3/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::eraseForbiddenArc ( std::string_view tail,
std::string_view head )

References BNLearner(), and eraseForbiddenArc().

Here is the call graph for this function:

◆ eraseMandatoryArc() [1/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::eraseMandatoryArc ( const Arc & arc)

References BNLearner(), and eraseMandatoryArc().

Referenced by eraseMandatoryArc(), eraseMandatoryArc(), and eraseMandatoryArc().

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

◆ eraseMandatoryArc() [2/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::eraseMandatoryArc ( NodeId tail,
NodeId head )

References BNLearner(), and eraseMandatoryArc().

Here is the call graph for this function:

◆ eraseMandatoryArc() [3/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::eraseMandatoryArc ( std::string_view tail,
std::string_view head )

References BNLearner(), and eraseMandatoryArc().

Here is the call graph for this function:

◆ eraseNoChildrenNode() [1/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::eraseNoChildrenNode ( NodeId node)

References BNLearner(), and eraseNoChildrenNode().

Referenced by eraseNoChildrenNode(), and eraseNoChildrenNode().

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

◆ eraseNoChildrenNode() [2/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::eraseNoChildrenNode ( std::string_view name)

References BNLearner(), and eraseNoChildrenNode().

Here is the call graph for this function:

◆ eraseNoParentNode() [1/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::eraseNoParentNode ( NodeId node)

References BNLearner(), and eraseNoParentNode().

Referenced by eraseNoParentNode(), and eraseNoParentNode().

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

◆ eraseNoParentNode() [2/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::eraseNoParentNode ( std::string_view name)

References BNLearner(), and eraseNoParentNode().

Here is the call graph for this function:

◆ erasePossibleEdge() [1/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::erasePossibleEdge ( const Edge & edge)

References BNLearner(), and erasePossibleEdge().

Referenced by erasePossibleEdge(), erasePossibleEdge(), and erasePossibleEdge().

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

◆ erasePossibleEdge() [2/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::erasePossibleEdge ( NodeId tail,
NodeId head )

References BNLearner(), and erasePossibleEdge().

Here is the call graph for this function:

◆ erasePossibleEdge() [3/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::erasePossibleEdge ( std::string_view tail,
std::string_view head )

References BNLearner(), and erasePossibleEdge().

Here is the call graph for this function:

◆ fciExhaustiveSepSet()

template<GUM_Numeric GUM_SCALAR>
bool gum::learning::BNLearner< GUM_SCALAR >::fciExhaustiveSepSet ( ) const

References fciExhaustiveSepSet().

Referenced by fciExhaustiveSepSet().

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

◆ forbidEM()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::forbidEM ( )

prevent using the EM algorithm for parameter learning

References BNLearner(), and forbidEM().

Referenced by forbidEM().

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

◆ G2() [1/2]

std::pair< double, double > gum::learning::IBNLearner::G2 ( NodeId id1,
NodeId id2,
const std::vector< NodeId > & knowing = {} )
inherited

Return the <statistic,pvalue> pair for for G2 test in the database.

Parameters
id1first variable
id2second variable
knowinglist of observed variables
Returns
a std::pair<double,double>

Definition at line 1387 of file IBNLearner.cpp.

1387 {
1388 createPrior_();
1389 gum::learning::IndepTestG2 g2score(scoreDatabase_.parser(), *prior_, databaseRanges());
1390 return g2score.statistics(id1, id2, knowing);
1391 }

References createPrior_(), databaseRanges(), gum::learning::IBNLearner::Database::parser(), prior_, scoreDatabase_, and gum::learning::IndepTestG2::statistics().

Referenced by G2().

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

◆ G2() [2/2]

std::pair< double, double > gum::learning::IBNLearner::G2 ( std::string_view name1,
std::string_view name2,
const std::vector< std::string > & knowing = {} )
inherited

Return the <statistic,pvalue> pair for for G2 test in the database.

Parameters
id1first variable
id2second variable
knowinglist of observed variables
Returns
a std::pair<double,double>

Definition at line 1393 of file IBNLearner.cpp.

1395 {
1396 std::vector< NodeId > knowingIds;
1397 std::transform(knowing.begin(),
1398 knowing.end(),
1399 std::back_inserter(knowingIds),
1400 [this](const std::string& c) { return this->idFromName(c); });
1401 return G2(idFromName(name1), idFromName(name2), knowingIds);
1402 }
std::pair< double, double > G2(NodeId id1, NodeId id2, const std::vector< NodeId > &knowing={})
Return the <statistic,pvalue> pair for for G2 test in the database.

References G2(), and idFromName().

Here is the call graph for this function:

◆ getNumberOfThreads()

◆ getPriorType_()

INLINE PriorType gum::learning::IBNLearner::getPriorType_ ( ) const
protectedinherited

returns the type (as a string) of a given prior

Definition at line 735 of file IBNLearner_inl.h.

735 {
736 switch (priorType_) {
738 case NO_prior : return PriorType::NoPriorType;
742 case BDEU : return PriorType::BDeuPriorType;
743 default :
744 GUM_ERROR(OperationNotAllowed,
745 "IBNLearner getPriorType does "
746 "not support yet this prior")
747 }
748 }
BNLearnerPriorType priorType_
the a priorselected for the score and parameters
BNLearnerPriorType
an enumeration to select the prior
Definition IBNLearner.h:117

References gum::learning::BDeuPriorType, gum::learning::DirichletPriorType, GUM_ERROR, gum::learning::NoPriorType, priorType_, and gum::learning::SmoothingPriorType.

Referenced by checkScorePriorCompatibility(), and createPrior_().

Here is the caller graph for this function:

◆ greedyThickThinningReversals()

template<GUM_Numeric GUM_SCALAR>
bool gum::learning::BNLearner< GUM_SCALAR >::greedyThickThinningReversals ( ) const

References greedyThickThinningReversals().

Referenced by greedyThickThinningReversals().

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

◆ hasMissingValues()

INLINE bool gum::learning::IBNLearner::hasMissingValues ( ) const
inherited

returns true if the learner's database has missing values

Definition at line 498 of file IBNLearner_inl.h.

498 {
500 }
bool hasMissingValues() const
indicates whether the database contains some missing values

References gum::learning::IBNLearner::Database::databaseTable(), gum::learning::IDatabaseTable< T_DATA >::hasMissingValues(), and scoreDatabase_.

Referenced by rawPseudoCount().

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

◆ history()

INLINE const std::vector< double > & gum::learning::IBNLearner::history ( ) const
overridevirtualinherited
Exceptions
OperationNotAllowedif scheme not performed or verbosity=false

Implements gum::IApproximationSchemeConfiguration.

Definition at line 995 of file IBNLearner_inl.h.

995 {
996 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->history();
997 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
998 }

References currentAlgorithm_, GUM_ERROR, and gum::ApproximationScheme::history().

Referenced by createPrior_().

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

◆ idFromName()

INLINE NodeId gum::learning::IBNLearner::idFromName ( std::string_view var_name) const
inherited

returns the node id corresponding to a variable name

Exceptions
MissingVariableInDatabaseif a variable of the BN is not found in the database.

Definition at line 137 of file IBNLearner_inl.h.

137 {
138 return scoreDatabase_.idFromName(var_name);
139 }
NodeId idFromName(std::string_view var_name) const
returns the node id corresponding to a variable name

References gum::learning::IBNLearner::Database::idFromName(), and scoreDatabase_.

Referenced by addForbiddenArc(), addMandatoryArc(), addNoChildrenNode(), addNoParentNode(), addPossibleEdge(), chi2(), correctedMutualInformation(), domainSize(), eraseForbiddenArc(), eraseMandatoryArc(), eraseNoChildrenNode(), eraseNoParentNode(), erasePossibleEdge(), G2(), logLikelihood(), mutualInformation(), rawPseudoCount(), score(), setSliceOrder(), and setTotalOrder().

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

◆ initialDAG()

INLINE DAG gum::learning::IBNLearner::initialDAG ( )
inherited

returns the initial DAG structure

Definition at line 167 of file IBNLearner_inl.h.

167{ return initialDag_; }
DAG initialDag_
an initial DAG given to learners

References initialDag_.

◆ isConstraintBased()

template<GUM_Numeric GUM_SCALAR>
bool gum::learning::BNLearner< GUM_SCALAR >::isConstraintBased ( ) const

References isConstraintBased().

Referenced by isConstraintBased().

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

◆ isCSVFileName_()

void gum::learning::IBNLearner::isCSVFileName_ ( std::string_view filename)
staticprotectedinherited

checks whether the extension of a CSV filename is correct

Definition at line 474 of file IBNLearner.cpp.

474 {
475 // get the extension of the file
476
477 if (auto filename_size = Size(filename.size()); filename_size < 4) {
478 GUM_ERROR(FormatNotFound,
479 "IBNLearner could not determine the "
480 "file type of the database")
481 }
482
483 std::string extension(filename.substr(filename.size() - 4));
484 std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
485
486 if (extension != ".csv") {
487 GUM_ERROR(OperationNotAllowed, "IBNLearner does not support yet this type of database file")
488 }
489 }

References GUM_ERROR.

Referenced by gum::learning::IBNLearner::Database::Database(), gum::learning::IBNLearner::Database::Database(), and readFile_().

Here is the caller graph for this function:

◆ isEnabledEpsilon()

INLINE bool gum::learning::IBNLearner::isEnabledEpsilon ( ) const
overridevirtualinherited
Returns
true if stopping criterion on epsilon is enabled, false otherwise

Implements gum::IApproximationSchemeConfiguration.

Definition at line 857 of file IBNLearner_inl.h.

857 {
858 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->isEnabledEpsilon();
859 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
860 }

References currentAlgorithm_, GUM_ERROR, and gum::ApproximationScheme::isEnabledEpsilon().

Referenced by createPrior_().

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

◆ isEnabledMaxIter()

INLINE bool gum::learning::IBNLearner::isEnabledMaxIter ( ) const
overridevirtualinherited
Returns
true if stopping criterion on max iterations is enabled, false otherwise

Implements gum::IApproximationSchemeConfiguration.

Definition at line 919 of file IBNLearner_inl.h.

919 {
920 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->isEnabledMaxIter();
921 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
922 }

References currentAlgorithm_, GUM_ERROR, and gum::ApproximationScheme::isEnabledMaxIter().

Referenced by createPrior_().

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

◆ isEnabledMaxTime()

INLINE bool gum::learning::IBNLearner::isEnabledMaxTime ( ) const
overridevirtualinherited
Returns
true if stopping criterion on timeout is enabled, false otherwise

Implements gum::IApproximationSchemeConfiguration.

Definition at line 955 of file IBNLearner_inl.h.

955 {
956 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->isEnabledMaxTime();
957 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
958 }

References currentAlgorithm_, GUM_ERROR, and gum::ApproximationScheme::isEnabledMaxTime().

Referenced by createPrior_().

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

◆ isEnabledMinEpsilonRate()

INLINE bool gum::learning::IBNLearner::isEnabledMinEpsilonRate ( ) const
overridevirtualinherited
Returns
true if stopping criterion on epsilon rate is enabled, false otherwise

Implements gum::IApproximationSchemeConfiguration.

Definition at line 888 of file IBNLearner_inl.h.

888 {
890 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
891 }

References currentAlgorithm_, GUM_ERROR, and gum::ApproximationScheme::isEnabledMinEpsilonRate().

Referenced by createPrior_().

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

◆ isGumNumberOfThreadsOverriden()

bool gum::ThreadNumberManager::isGumNumberOfThreadsOverriden ( ) const
nodiscardoverridevirtualinherited

indicates whether the class containing this ThreadNumberManager set its own number of threads

Implements gum::IThreadNumberManager.

Referenced by gum::learning::IBNLearner::createParamEstimator_(), gum::learning::IBNLearner::createScore_(), gum::ScheduledInference::operator=(), and gum::ScheduledInference::operator=().

Here is the caller graph for this function:

◆ isScoreBased()

template<GUM_Numeric GUM_SCALAR>
bool gum::learning::BNLearner< GUM_SCALAR >::isScoreBased ( ) const

References isScoreBased().

Referenced by isScoreBased().

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

◆ isUsingEM()

INLINE bool gum::learning::IBNLearner::isUsingEM ( ) const
inherited

indicates whether we use EM for parameter learning

Definition at line 464 of file IBNLearner_inl.h.

464{ return useEM_; }

References useEM_.

◆ latentVariables()

INLINE std::vector< Arc > gum::learning::IBNLearner::latentVariables ( ) const
inherited

get the list of arcs hiding latent variables

Exceptions
OperationNotAllowedwhen MIIC is not the selected algorithm

Definition at line 346 of file IBNLearner_inl.h.

346 {
347 return algoMiic_.latentVariables();
348 }
const std::vector< Arc > latentVariables() const
Miic algoMiic_
the Constraint MIIC algorithm

References algoMiic_, and gum::learning::ConstraintBasedLearning::latentVariables().

Here is the call graph for this function:

◆ learnBN()

template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR > gum::learning::BNLearner< GUM_SCALAR >::learnBN ( )

learn a Bayes Net from a file (must have read the db before)

References learnBN().

Referenced by learnBN().

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

◆ learnDAG()

DAG gum::learning::IBNLearner::learnDAG ( )
inherited

learn a structure from a file (must have read the db before)

Definition at line 986 of file IBNLearner.cpp.

986 {
987 createPrior_();
988 createScore_();
989 auto dag = learnDag_();
990 for (const auto i: dag) {
991 dag.setName(i, scoreDatabase_.databaseTable().variableName(i));
992 }
993 return dag;
994 }
DAG learnDag_()
returns the DAG learnt
void createScore_()
create the score used for learning
const std::string & variableName(const std::size_t k) const
returns the name of the kth column of the IDatabaseTable

References createPrior_(), createScore_(), gum::learning::IBNLearner::Database::databaseTable(), learnDag_(), scoreDatabase_, and gum::learning::IDatabaseTable< T_DATA >::variableName().

Here is the call graph for this function:

◆ learnDag_()

DAG gum::learning::IBNLearner::learnDag_ ( )
protectedinherited

returns the DAG learnt

Definition at line 1015 of file IBNLearner.cpp.

1015 {
1016 // check that the database does not contain any missing value
1018 || ((priorDatabase_ != nullptr)
1021 GUM_ERROR(MissingValueInDatabase,
1022 "For the moment, the BNLearner is unable to cope "
1023 "with missing values in databases")
1024 }
1025 // add the mandatory arcs to the initial dag and remove the forbidden ones
1026 // from the initial graph
1027 DAG init_graph = initialDag_;
1028
1029 for (const auto& arc: constraintMandatoryArcs_.arcs()) {
1030 if (!init_graph.exists(arc.tail())) init_graph.addNodeWithId(arc.tail());
1031
1032 if (!init_graph.exists(arc.head())) init_graph.addNodeWithId(arc.head());
1033
1034 init_graph.addArc(arc.tail(), arc.head());
1035 }
1036
1037 for (const auto& arc: constraintForbiddenArcs_.arcs())
1038 init_graph.eraseArc(arc);
1039
1040
1041 switch (selectedAlgo_) {
1042 // ========================================================================
1043 case AlgoType::PC : {
1044 BNLearnerListener listener(this, algoPC_);
1045 MixedGraph mgraph = this->preparePC_();
1046 return algoPC_.learnDAG(mgraph);
1047 }
1048
1049 // ========================================================================
1050 case AlgoType::FCI : {
1051 BNLearnerListener listener(this, algoFCI_);
1052 MixedGraph mgraph = this->prepareFCI_();
1053 return algoFCI_.learnDAG(mgraph);
1054 }
1055
1056 // ========================================================================
1057 case AlgoType::MIIC : {
1058 BNLearnerListener listener(this, algoMiic_);
1059 // create the mixedGraph and the corrected mutual information
1060 MixedGraph mgraph = this->prepareMiic_();
1061
1063 return algoMiic_.learnDAG(mgraph);
1064 }
1065
1066 // ========================================================================
1068 BNLearnerListener listener(this, greedyHillClimbing_);
1069 StructuralConstraintSetStatic< StructuralConstraintMandatoryArcs,
1070 StructuralConstraintForbiddenArcs,
1071 StructuralConstraintPossibleEdges,
1072 StructuralConstraintSliceOrder,
1073 StructuralConstraintNoParentNodes,
1074 StructuralConstraintNoChildrenNodes,
1075 StructuralConstraintTotalOrder >
1076 invariable_constraints;
1077 static_cast< StructuralConstraintMandatoryArcs& >(invariable_constraints)
1079 static_cast< StructuralConstraintForbiddenArcs& >(invariable_constraints)
1081 static_cast< StructuralConstraintPossibleEdges& >(invariable_constraints)
1083 static_cast< StructuralConstraintSliceOrder& >(invariable_constraints)
1085 static_cast< StructuralConstraintNoParentNodes& >(invariable_constraints)
1087 static_cast< StructuralConstraintNoChildrenNodes& >(invariable_constraints)
1089 static_cast< StructuralConstraintTotalOrder& >(invariable_constraints)
1091
1092 StructuralConstraintSetStatic< StructuralConstraintIndegree, StructuralConstraintDAG >
1093 variable_constraints;
1094 static_cast< StructuralConstraintIndegree& >(variable_constraints) = constraintIndegree_;
1095
1096 GraphChangesSelector4DiGraph selector(*score_,
1097 invariable_constraints,
1098 variable_constraints);
1099
1100 // enforce that greedy hill climbing uses arc additions, deletions and reversals
1101 // and only these operations
1102 selector.useArcAdditions(true);
1103 selector.useArcDeletions(true);
1104 selector.useArcReversals(true);
1105 selector.useArcTriangleDeletions(false);
1106
1107 return greedyHillClimbing_.learnStructure(selector, init_graph);
1108 }
1109
1110 // ========================================================================
1112 BNLearnerListener listener(this, extendedGreedyHillClimbing_);
1113 StructuralConstraintSetStatic< StructuralConstraintMandatoryArcs,
1114 StructuralConstraintForbiddenArcs,
1115 StructuralConstraintPossibleEdges,
1116 StructuralConstraintNoParentNodes,
1117 StructuralConstraintNoChildrenNodes,
1118 StructuralConstraintSliceOrder,
1119 StructuralConstraintTotalOrder >
1120 invariable_constraints;
1121 static_cast< StructuralConstraintMandatoryArcs& >(invariable_constraints)
1123 static_cast< StructuralConstraintForbiddenArcs& >(invariable_constraints)
1125 static_cast< StructuralConstraintPossibleEdges& >(invariable_constraints)
1127 static_cast< StructuralConstraintSliceOrder& >(invariable_constraints)
1129 static_cast< StructuralConstraintNoParentNodes& >(invariable_constraints)
1131 static_cast< StructuralConstraintNoChildrenNodes& >(invariable_constraints)
1133 static_cast< StructuralConstraintTotalOrder& >(invariable_constraints)
1135
1136 StructuralConstraintSetStatic< StructuralConstraintIndegree, StructuralConstraintDAG >
1137 variable_constraints;
1138 static_cast< StructuralConstraintIndegree& >(variable_constraints) = constraintIndegree_;
1139
1140 GraphChangesSelector4DiGraph selector(*score_,
1141 invariable_constraints,
1142 variable_constraints);
1143
1144 selector.useArcAdditions(allowArcAdditions_);
1145 selector.useArcDeletions(allowArcDeletions_);
1146 selector.useArcReversals(allowArcReversals_);
1147 selector.useArcTriangleDeletions(allowArcTriangleDeletions_);
1148
1149 return greedyHillClimbing_.learnStructure(selector, init_graph);
1150 }
1151
1152 // ========================================================================
1154 BNLearnerListener listener(this, greedyThickThinning_);
1155 StructuralConstraintSetStatic< StructuralConstraintMandatoryArcs,
1156 StructuralConstraintForbiddenArcs,
1157 StructuralConstraintPossibleEdges,
1158 StructuralConstraintSliceOrder,
1159 StructuralConstraintNoParentNodes,
1160 StructuralConstraintNoChildrenNodes,
1161 StructuralConstraintTotalOrder >
1162 invariable_constraints;
1163 static_cast< StructuralConstraintMandatoryArcs& >(invariable_constraints)
1165 static_cast< StructuralConstraintForbiddenArcs& >(invariable_constraints)
1167 static_cast< StructuralConstraintPossibleEdges& >(invariable_constraints)
1169 static_cast< StructuralConstraintSliceOrder& >(invariable_constraints)
1171 static_cast< StructuralConstraintNoParentNodes& >(invariable_constraints)
1173 static_cast< StructuralConstraintNoChildrenNodes& >(invariable_constraints)
1175 static_cast< StructuralConstraintTotalOrder& >(invariable_constraints)
1177
1178 StructuralConstraintSetStatic< StructuralConstraintIndegree, StructuralConstraintDAG >
1179 variable_constraints;
1180 static_cast< StructuralConstraintIndegree& >(variable_constraints) = constraintIndegree_;
1181
1182 GraphChangesSelector4DiGraph selector(*score_,
1183 invariable_constraints,
1184 variable_constraints);
1185
1186 return greedyThickThinning_.learnStructure(selector, init_graph);
1187 }
1188
1189 // ========================================================================
1191 BNLearnerListener listener(this, localSearchWithTabuList_);
1192 StructuralConstraintSetStatic< StructuralConstraintMandatoryArcs,
1193 StructuralConstraintForbiddenArcs,
1194 StructuralConstraintPossibleEdges,
1195 StructuralConstraintSliceOrder,
1196 StructuralConstraintNoParentNodes,
1197 StructuralConstraintNoChildrenNodes,
1198 StructuralConstraintTotalOrder >
1199 invariable_constraints;
1200 static_cast< StructuralConstraintMandatoryArcs& >(invariable_constraints)
1202 static_cast< StructuralConstraintForbiddenArcs& >(invariable_constraints)
1204 static_cast< StructuralConstraintPossibleEdges& >(invariable_constraints)
1206 static_cast< StructuralConstraintSliceOrder& >(invariable_constraints)
1208 static_cast< StructuralConstraintNoParentNodes& >(invariable_constraints)
1210 static_cast< StructuralConstraintNoChildrenNodes& >(invariable_constraints)
1212 static_cast< StructuralConstraintTotalOrder& >(invariable_constraints)
1214
1215 StructuralConstraintSetStatic< StructuralConstraintTabuList,
1216 StructuralConstraintIndegree,
1217 StructuralConstraintDAG >
1218 variable_constraints;
1219 static_cast< StructuralConstraintTabuList& >(variable_constraints) = constraintTabuList_;
1220 static_cast< StructuralConstraintIndegree& >(variable_constraints) = constraintIndegree_;
1221
1222 GraphChangesSelector4DiGraph selector(*score_,
1223 invariable_constraints,
1224 variable_constraints);
1225
1226 selector.useArcAdditions(allowArcAdditions_);
1227 selector.useArcDeletions(allowArcDeletions_);
1228 selector.useArcReversals(allowArcReversals_);
1229 selector.useArcTriangleDeletions(allowArcTriangleDeletions_);
1230
1231 return localSearchWithTabuList_.learnStructure(selector, init_graph);
1232 }
1233
1234 // ========================================================================
1235 case AlgoType::K2 : {
1236 BNLearnerListener listener(this, algoK2_.approximationScheme());
1237 StructuralConstraintSetStatic< StructuralConstraintMandatoryArcs,
1238 StructuralConstraintForbiddenArcs,
1239 StructuralConstraintPossibleEdges,
1240 StructuralConstraintNoParentNodes,
1241 StructuralConstraintNoChildrenNodes,
1242 StructuralConstraintTotalOrder >
1243 invariable_constraints;
1244 static_cast< StructuralConstraintMandatoryArcs& >(invariable_constraints)
1246 static_cast< StructuralConstraintForbiddenArcs& >(invariable_constraints)
1248 static_cast< StructuralConstraintPossibleEdges& >(invariable_constraints)
1250 static_cast< StructuralConstraintNoParentNodes& >(invariable_constraints)
1252 static_cast< StructuralConstraintNoChildrenNodes& >(invariable_constraints)
1254 static_cast< StructuralConstraintTotalOrder& >(invariable_constraints)
1256
1257 // if some mandatory arcs are incompatible with the order, use a DAG
1258 // constraint instead of a DiGraph constraint to avoid cycles
1259 const ArcSet& mandatory_arcs
1260 = static_cast< StructuralConstraintMandatoryArcs& >(invariable_constraints).arcs();
1261 const Sequence< NodeId >& order = algoK2_.order();
1262 bool order_compatible = true;
1263
1264 for (const auto& arc: mandatory_arcs) {
1265 if (order.pos(arc.tail()) >= order.pos(arc.head())) {
1266 order_compatible = false;
1267 break;
1268 }
1269 }
1270
1271 if (order_compatible) {
1272 StructuralConstraintSetStatic< StructuralConstraintIndegree, StructuralConstraintDiGraph >
1273 variable_constraints;
1274 static_cast< StructuralConstraintIndegree& >(variable_constraints) = constraintIndegree_;
1275
1276 GraphChangesSelector4DiGraph selector(*score_,
1277 invariable_constraints,
1278 variable_constraints);
1279
1280 return algoK2_.learnStructure(selector, init_graph);
1281 } else {
1282 StructuralConstraintSetStatic< StructuralConstraintIndegree, StructuralConstraintDAG >
1283 variable_constraints;
1284 static_cast< StructuralConstraintIndegree& >(variable_constraints) = constraintIndegree_;
1285
1286 GraphChangesSelector4DiGraph selector(*score_,
1287 invariable_constraints,
1288 variable_constraints);
1289
1290 return algoK2_.learnStructure(selector, init_graph);
1291 }
1292 }
1293 }
1294
1295 GUM_ERROR(OperationNotAllowed,
1296 "the learnDAG method has not been implemented for this "
1297 "learning algorithm")
1298 }
virtual void eraseArc(const Arc &arc)
removes an arc from the ArcGraphPart
DAG learnDAG(MixedGraph graph)
learns a DAG
DAG learnStructure(GRAPH_CHANGES_SELECTOR &selector, DAG initial_dag=DAG())
learns the structure of a Bayes net
DAG learnStructure(GRAPH_CHANGES_SELECTOR &selector, DAG initial_dag=DAG())
learns the structure of a Bayes net
StructuralConstraintPossibleEdges constraintPossibleEdges_
the constraint on possible Edges
MixedGraph preparePC_()
prepares the initial graph and independence test for PC
StructuralConstraintNoParentNodes constraintNoParentNodes_
the constraint on no parent nodes
GreedyHillClimbing extendedGreedyHillClimbing_
the extended greedy hill climbing
bool allowArcTriangleDeletions_
whether we allow or not arc deletions during learning
AlgoType selectedAlgo_
the learning algorithm ; it is initialized from the configuration, see preferredAlgo()
bool allowArcAdditions_
whether we allow or not arc additions during learning
StructuralConstraintNoChildrenNodes constraintNoChildrenNodes_
the constraint on no children nodes
gum::learning::FCI algoFCI_
the FCI algorithm
Database * priorDatabase_
the database used by the Dirichlet a priori
StructuralConstraintIndegree constraintIndegree_
the constraint for indegrees
bool allowArcDeletions_
whether we allow or not arc deletions during learning
StructuralConstraintMandatoryArcs constraintMandatoryArcs_
the constraint on mandatory arcs
StructuralConstraintForbiddenArcs constraintForbiddenArcs_
the constraint on forbidden arcs
StructuralConstraintTotalOrder constraintTotalOrder_
the total order ing constraint
StructuralConstraintTabuList constraintTabuList_
the constraint for tabu lists
GreedyThickThinning greedyThickThinning_
the greedy thick-thinning algorithm
MixedGraph prepareFCI_()
prepares the initial graph and independence test for FCI
gum::learning::PC algoPC_
the PC algorithm
bool allowArcReversals_
whether we allow or not arc reversals during learning
MixedGraph prepareMiic_()
prepares the initial graph for miic
StructuralConstraintSliceOrder constraintSliceOrder_
the constraint for 2TBNs
const Sequence< NodeId > & order() const noexcept
returns the current order
DAG learnStructure(GRAPH_CHANGES_SELECTOR &selector, DAG initial_dag=DAG())
learns the structure of a Bayes net
Definition K2_tpl.h:63
DAG learnStructure(GRAPH_CHANGES_SELECTOR &selector, DAG initial_dag=DAG())
learns the structure of a Bayes net
void setMutualInformation(CorrectedMutualInformation &mi)
Definition Miic.cpp:89
const ArcSet & arcs() const
returns the set of mandatory arcs
const ArcSet & arcs() const
returns the set of mandatory arcs
Set< Arc > ArcSet
Some typdefs and define for shortcuts ...

References gum::DAG::addArc(), gum::NodeGraphPart::addNodeWithId(), algoFCI_, algoK2_, algoMiic_, algoPC_, allowArcAdditions_, allowArcDeletions_, allowArcReversals_, allowArcTriangleDeletions_, gum::learning::K2::approximationScheme(), gum::learning::StructuralConstraintForbiddenArcs::arcs(), gum::learning::StructuralConstraintMandatoryArcs::arcs(), constraintForbiddenArcs_, constraintIndegree_, constraintMandatoryArcs_, constraintNoChildrenNodes_, constraintNoParentNodes_, constraintPossibleEdges_, constraintSliceOrder_, constraintTabuList_, constraintTotalOrder_, gum::learning::IBNLearner::Database::databaseTable(), DIRICHLET_FROM_DATABASE, gum::ArcGraphPart::eraseArc(), gum::NodeGraphPart::exists(), EXTENDED_GREEDY_HILL_CLIMBING, extendedGreedyHillClimbing_, FCI, GREEDY_HILL_CLIMBING, GREEDY_THICK_THINNING, greedyHillClimbing_, greedyThickThinning_, GUM_ERROR, gum::learning::IDatabaseTable< T_DATA >::hasMissingValues(), initialDag_, K2, gum::learning::ConstraintBasedLearning::learnDAG(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::GreedyThickThinning::learnStructure(), gum::learning::K2::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), LOCAL_SEARCH_WITH_TABU_LIST, localSearchWithTabuList_, MIIC, mutualInfo_, gum::learning::K2::order(), PC, gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::pos(), prepareFCI_(), prepareMiic_(), preparePC_(), priorDatabase_, priorType_, score_, scoreDatabase_, selectedAlgo_, gum::learning::Miic::setMutualInformation(), gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::useArcAdditions(), gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::useArcDeletions(), gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::useArcReversals(), and gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::useArcTriangleDeletions().

Referenced by createPrior_(), and learnDAG().

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

◆ learnPAG()

PAG gum::learning::IBNLearner::learnPAG ( )
inherited

learn a PAG — only valid when useFCI() has been called

Exceptions
OperationNotAllowedwhen FCI is not the selected algorithm

Definition at line 978 of file IBNLearner.cpp.

978 {
979 auto pag = learnPAG_();
980 for (const auto i: pag) {
981 pag.setName(i, scoreDatabase_.databaseTable().variableName(i));
982 }
983 return pag;
984 }

References gum::learning::IBNLearner::Database::databaseTable(), learnPAG_(), scoreDatabase_, and gum::learning::IDatabaseTable< T_DATA >::variableName().

Here is the call graph for this function:

◆ learnPAG_()

PAG gum::learning::IBNLearner::learnPAG_ ( )
protectedinherited

Definition at line 964 of file IBNLearner.cpp.

964 {
966 GUM_ERROR(OperationNotAllowed, "learnPAG() is only valid when using the FCI algorithm")
967 }
969 GUM_ERROR(MissingValueInDatabase,
970 "For the moment, the BNLearner is unable to learn "
971 << "structures with missing values in databases")
972 }
973 BNLearnerListener listener(this, algoFCI_);
974 MixedGraph mgraph = this->prepareFCI_();
975 return algoFCI_.learnPAG(mgraph);
976 }
PAG learnPAG(MixedGraph graph)
primary FCI output: learn a PAG from the given node-only or partial graph
Definition FCI.cpp:818

References algoFCI_, gum::learning::IBNLearner::Database::databaseTable(), FCI, GUM_ERROR, gum::learning::IDatabaseTable< T_DATA >::hasMissingValues(), gum::learning::FCI::learnPAG(), prepareFCI_(), scoreDatabase_, and selectedAlgo_.

Referenced by learnPAG().

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

◆ learnParameters() [1/3]

template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR > gum::learning::BNLearner< GUM_SCALAR >::learnParameters ( bool take_into_account_score = true)

learns a BN (its parameters) when its structure is known

Parameters
take_into_account_scoreThe 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 prior (like K2 which has a 1-smoothing prior), it is important to also take into account this implicit prior for parameter learning. By default, if a score exists, we will learn parameters by taking into account the prior specified by methods usePriorXXX () + the implicit prior of the score, else we just take into account the prior specified by usePriorXXX ()
Warning
if method useEM() has been executed, then the learning is performed using EM, else this is a standard (e.g. ML/MAP) learning
Exceptions
MissingVariableInDatabaseif a variable of the BN is not found in the database.
UnknownLabelInDatabaseif a label is found in the databast that do not correpond to the variable.
OperationNotAllowedif EM is used but neither the min log-likelihood difference nor the min log-likelihood evolution rate have been selected as stopping criteria

References learnParameters().

Here is the call graph for this function:

◆ learnParameters() [2/3]

template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR > gum::learning::BNLearner< GUM_SCALAR >::learnParameters ( const BayesNet< GUM_SCALAR > & bn,
bool takeIntoAccountScore = true )

learns a BN (its parameters) with the BN structure passed in argument, EM being initialized by this argument

Parameters
bnthe Bayesian network used to specify the graphical structure of the returned Bayes net and to initialize its CPTs before running EM. When a CPT is filled exclusively with only zeroes, then this one is initialized by the BNLearner using a specific estimator that does not take into account the missing values in the database
takeIntoAccountScoreThe 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 prior (like K2 which has a 1-smoothing prior), it is important to also take into account this implicit prior for parameter learning. By default, if a score exists, we will learn parameters by taking into account the prior specified by methods usePriorXXX () + the implicit prior of the score, else we just take into account the prior specified by usePriorXXX ()
Exceptions
MissingVariableInDatabaseif a variable of the BN is not found in the database.
OperationNotAllowedif EM is used but no EM stopping criterion has been selected.
Warning
if method useEM() has been executed, then the learning is performed using EM, else this is a standard (e.g. ML/MAP) learning
the EM algorithm initializes the parameters of the CPTs using those of the Bayes net passed in argument whenever those are not fully filled with zeroes, else the BNLearner initializes them using an estimator that does not take into account the missing values. If you wish the BNLearner to automatically initialize all the CPTs, use the method in which a DAG is passed in argument rather than a Bayes net.

References learnParameters().

Here is the call graph for this function:

◆ learnParameters() [3/3]

template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR > gum::learning::BNLearner< GUM_SCALAR >::learnParameters ( const DAG & dag,
bool takeIntoAccountScore = true )

learns a BN (its parameters) with the structure passed in argument

Parameters
dagthe structure of the Bayesian network
takeIntoAccountScoreThe 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 prior (like K2 which has a 1-smoothing prior), it is important to also take into account this implicit prior for parameter learning. By default, if a score exists, we will learn parameters by taking into account the prior specified by methods usePriorXXX () + the implicit prior of the score, else we just take into account the prior specified by usePriorXXX ()
Exceptions
MissingVariableInDatabaseif a variable of the BN is not found in the database.
MissingValueInDatabaseif the database contains some missing values and EM is not used for the learning.
OperationNotAllowedif EM is used but no EM stopping criterion has been selected.
Warning
if method useEM() has been executed, then the learning is performed using EM, else this is a standard (e.g. ML/MAP) learning

References learnParameters().

Referenced by learnParameters(), learnParameters(), and learnParameters().

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

◆ learnPDAG()

PDAG gum::learning::IBNLearner::learnPDAG ( )
inherited

learn a partial structure from a file (must have read the db before and must have selected miic)

Definition at line 956 of file IBNLearner.cpp.

956 {
957 auto pdag = learnPDAG_();
958 for (const auto i: pdag) {
959 pdag.setName(i, scoreDatabase_.databaseTable().variableName(i));
960 }
961 return pdag;
962 }

References gum::learning::IBNLearner::Database::databaseTable(), learnPDAG_(), scoreDatabase_, and gum::learning::IDatabaseTable< T_DATA >::variableName().

Here is the call graph for this function:

◆ learnPDAG_()

PDAG gum::learning::IBNLearner::learnPDAG_ ( )
protectedinherited

Definition at line 923 of file IBNLearner.cpp.

923 {
926 GUM_ERROR(OperationNotAllowed,
927 "Score-based algorithms do not build PDAG. Please use a constraint-based "
928 "algorithm instead")
929 }
930 // check that the database does not contain any missing value
932 GUM_ERROR(MissingValueInDatabase,
933 "For the moment, the BNLearner is unable to learn "
934 << "structures with missing values in databases")
935 }
936
938 BNLearnerListener listener(this, algoPC_);
939 MixedGraph mgraph = this->preparePC_();
940 return algoPC_.learnPDAG(mgraph);
941 }
942
944 BNLearnerListener listener(this, algoFCI_);
945 MixedGraph mgraph = this->prepareFCI_();
946 return algoFCI_.learnPDAG(mgraph);
947 }
948
949 BNLearnerListener listener(this, algoMiic_);
950 // create the mixedGraph_constraint_MandatoryArcs.arcs
951 MixedGraph mgraph = this->prepareMiic_();
953 return algoMiic_.learnPDAG(mgraph);
954 }
PDAG learnPDAG(MixedGraph graph)
learns the essential graph (CPDAG)

References algoFCI_, algoMiic_, algoPC_, gum::learning::IBNLearner::Database::databaseTable(), FCI, GUM_ERROR, gum::learning::IDatabaseTable< T_DATA >::hasMissingValues(), gum::learning::ConstraintBasedLearning::learnPDAG(), MIIC, mutualInfo_, PC, prepareFCI_(), prepareMiic_(), preparePC_(), scoreDatabase_, selectedAlgo_, and gum::learning::Miic::setMutualInformation().

Referenced by learnPDAG().

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

◆ logLikelihood() [1/2]

double gum::learning::IBNLearner::logLikelihood ( const std::vector< NodeId > & vars,
const std::vector< NodeId > & knowing = {} )
inherited

Return the loglikelihood of vars in the base, conditioned by knowing for the BNLearner.

Parameters
varsa vector of NodeIds
knowingan optional vector of conditioning NodeIds
Returns
a double

Definition at line 1404 of file IBNLearner.cpp.

1405 {
1406 createPrior_();
1407 gum::learning::ScoreLog2Likelihood ll2score(scoreDatabase_.parser(), *prior_, databaseRanges());
1408
1409 std::vector< NodeId > total(vars);
1410 total.insert(total.end(), knowing.begin(), knowing.end());
1411 double LLtotal = ll2score.score(IdCondSet(total, false, true));
1412 if (knowing.size() == (Size)0) {
1413 return LLtotal;
1414 } else {
1415 double LLknw = ll2score.score(IdCondSet(knowing, false, true));
1416 return LLtotal - LLknw;
1417 }
1418 }
IdCondSet()
default constructor

References gum::learning::IdCondSet::IdCondSet(), createPrior_(), databaseRanges(), gum::learning::IBNLearner::Database::parser(), prior_, gum::learning::ScoreLog2Likelihood::score(), and scoreDatabase_.

Referenced by logLikelihood().

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

◆ logLikelihood() [2/2]

double gum::learning::IBNLearner::logLikelihood ( const std::vector< std::string > & vars,
const std::vector< std::string > & knowing = {} )
inherited

Return the loglikelihood of vars in the base, conditioned by knowing for the BNLearner.

Parameters
varsa vector of name of rows
knowingan optional vector of conditioning rows
Returns
a double

Definition at line 1420 of file IBNLearner.cpp.

1421 {
1422 std::vector< NodeId > ids;
1423 std::vector< NodeId > knowingIds;
1424
1425 auto mapper = [this](const std::string& c) { return this->idFromName(c); };
1426
1427 std::transform(vars.begin(), vars.end(), std::back_inserter(ids), mapper);
1428 std::transform(knowing.begin(), knowing.end(), std::back_inserter(knowingIds), mapper);
1429
1430 return logLikelihood(ids, knowingIds);
1431 }
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.

References idFromName(), and logLikelihood().

Here is the call graph for this function:

◆ maxIter()

INLINE Size gum::learning::IBNLearner::maxIter ( ) const
overridevirtualinherited
Returns
the criterion on number of iterations

Implements gum::IApproximationSchemeConfiguration.

Definition at line 900 of file IBNLearner_inl.h.

900 {
901 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->maxIter();
902 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
903 }

References currentAlgorithm_, GUM_ERROR, and gum::ApproximationScheme::maxIter().

Referenced by createPrior_().

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

◆ maxTime()

INLINE double gum::learning::IBNLearner::maxTime ( ) const
overridevirtualinherited

returns the timeout (in seconds)

Implements gum::IApproximationSchemeConfiguration.

Definition at line 931 of file IBNLearner_inl.h.

931 {
932 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->maxTime();
933 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
934 }

References currentAlgorithm_, GUM_ERROR, and gum::ApproximationScheme::maxTime().

Referenced by createPrior_().

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

◆ messageApproximationScheme()

std::string gum::IApproximationSchemeConfiguration::messageApproximationScheme ( ) const
inherited

Returns the approximation scheme message.

Returns
Returns the approximation scheme message.

Definition at line 64 of file IApproximationSchemeConfiguration.cpp.

64 {
65 switch (stateApproximationScheme()) {
66 case ApproximationSchemeSTATE::Continue : return "in progress";
67
69 return std::format("stopped with epsilon={}", epsilon());
70
72 return std::format("stopped with rate={}", minEpsilonRate());
73
75 return std::format("stopped with max iteration={}", maxIter());
76
78 return std::format("stopped with timeout={}", maxTime());
79
80 case ApproximationSchemeSTATE::Stopped : return "stopped on request";
81
82 case ApproximationSchemeSTATE::Undefined : return "undefined state";
83 }
84 return {};
85 }
virtual double epsilon() const =0
Returns the value of epsilon.
virtual ApproximationSchemeSTATE stateApproximationScheme() const =0
Returns the approximation scheme state.
virtual double minEpsilonRate() const =0
Returns the value of the minimal epsilon rate.
virtual Size maxIter() const =0
Returns the criterion on number of iterations.
virtual double maxTime() const =0
Returns the timeout (in seconds).

References Continue, Epsilon, epsilon(), Limit, maxIter(), maxTime(), minEpsilonRate(), Rate, stateApproximationScheme(), Stopped, TimeLimit, and Undefined.

Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::learning::IBNLearner::EMStateMessage(), and gum::credal::InferenceEngine< GUM_SCALAR >::getApproximationSchemeMsg().

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

◆ minEpsilonRate()

INLINE double gum::learning::IBNLearner::minEpsilonRate ( ) const
overridevirtualinherited

Get the value of the minimal epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 869 of file IBNLearner_inl.h.

869 {
870 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->minEpsilonRate();
871 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
872 }

References currentAlgorithm_, GUM_ERROR, and gum::ApproximationScheme::minEpsilonRate().

Referenced by createPrior_().

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

◆ mutualInformation() [1/2]

double gum::learning::IBNLearner::mutualInformation ( NodeId id1,
NodeId id2,
const std::vector< NodeId > & knowing = {} )
inherited

Return the mutual information of id1 and id2 in the base, conditioned by knowing for the BNLearner.

Warning
This function returns the bare mutual information (without prior or correction)
Parameters
id1nodeId
id2nodeId
knowingan optional vector of conditioning NodeIds
Returns
a double

Definition at line 1470 of file IBNLearner.cpp.

1472 {
1474 gum::learning::CorrectedMutualInformation cmi(scoreDatabase_.parser(), prior, databaseRanges());
1475 cmi.useNoCorr();
1476
1477 if (knowing.size() == (Size)0) return cmi.score(id1, id2) / scoreDatabase_.weight();
1478 else return cmi.score(id1, id2, knowing) / scoreDatabase_.weight();
1479 }
NoPrior(const DatabaseTable &database, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor

References gum::learning::NoPrior::NoPrior(), databaseRanges(), gum::learning::IBNLearner::Database::databaseTable(), gum::learning::IBNLearner::Database::nodeId2Columns(), gum::learning::IBNLearner::Database::parser(), gum::learning::CorrectedMutualInformation::score(), scoreDatabase_, gum::learning::CorrectedMutualInformation::useNoCorr(), and gum::learning::IBNLearner::Database::weight().

Referenced by mutualInformation().

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

◆ mutualInformation() [2/2]

double gum::learning::IBNLearner::mutualInformation ( std::string_view var1,
std::string_view var2,
const std::vector< std::string > & knowing = {} )
inherited

Return the mutual information of var1 and var2 in the base, conditioned by knowing for the BNLearner.

Warning
This function returns the bare mutual information (without prior or correction)
Parameters
var1name of a row
var2name of a row
knowingan optional vector of conditioning rows
Returns
a double

Definition at line 1481 of file IBNLearner.cpp.

1483 {
1484 std::vector< NodeId > knowingIds;
1485
1486 auto mapper = [this](const std::string& c) { return this->idFromName(c); };
1487
1488 std::transform(knowing.begin(), knowing.end(), std::back_inserter(knowingIds), mapper);
1489
1490 return mutualInformation(this->idFromName(var1), this->idFromName(var2), knowingIds);
1491 }
double mutualInformation(NodeId id1, NodeId id2, const std::vector< NodeId > &knowing={})
Return the mutual information of id1 and id2 in the base, conditioned by knowing for the BNLearner.

References idFromName(), and mutualInformation().

Here is the call graph for this function:

◆ nameFromId()

INLINE const std::string & gum::learning::IBNLearner::nameFromId ( NodeId id) const
inherited

returns the variable name corresponding to a given node id

Definition at line 142 of file IBNLearner_inl.h.

142 {
143 return scoreDatabase_.nameFromId(id);
144 }
const std::string & nameFromId(NodeId id) const
returns the variable name corresponding to a given node id

References gum::learning::IBNLearner::Database::nameFromId(), and scoreDatabase_.

Here is the call graph for this function:

◆ names()

INLINE const std::vector< std::string > & gum::learning::IBNLearner::names ( ) const
inherited

returns the names of the variables in the database

Definition at line 751 of file IBNLearner_inl.h.

751 {
752 return scoreDatabase_.names();
753 }
const std::vector< std::string > & names() const
returns the names of the variables in the database

References gum::learning::IBNLearner::Database::names(), and scoreDatabase_.

Here is the call graph for this function:

◆ nbCols()

INLINE Size gum::learning::IBNLearner::nbCols ( ) const
inherited
Returns
the number of cols in the database

Definition at line 782 of file IBNLearner_inl.h.

782{ return scoreDatabase_.domainSizes().size(); }

References gum::learning::IBNLearner::Database::domainSizes(), and scoreDatabase_.

Here is the call graph for this function:

◆ nbrIterations()

INLINE Size gum::learning::IBNLearner::nbrIterations ( ) const
overridevirtualinherited
Exceptions
OperationNotAllowedif scheme not performed

Implements gum::IApproximationSchemeConfiguration.

Definition at line 990 of file IBNLearner_inl.h.

990 {
991 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->nbrIterations();
992 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
993 }

References currentAlgorithm_, GUM_ERROR, and gum::ApproximationScheme::nbrIterations().

Referenced by createPrior_().

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

◆ nbRows()

INLINE Size gum::learning::IBNLearner::nbRows ( ) const
inherited
Returns
the number of rows in the database

Definition at line 784 of file IBNLearner_inl.h.

784{ return scoreDatabase_.databaseTable().size(); }
std::size_t size() const noexcept
returns the number of records (rows) in the database

References gum::learning::IBNLearner::Database::databaseTable(), scoreDatabase_, and gum::learning::IDatabaseTable< T_DATA >::size().

Here is the call graph for this function:

◆ operator=() [1/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner & gum::learning::BNLearner< GUM_SCALAR >::operator= ( BNLearner< GUM_SCALAR > && )
noexcept

move operator

References BNLearner().

Here is the call graph for this function:

◆ operator=() [2/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner & gum::learning::BNLearner< GUM_SCALAR >::operator= ( const BNLearner< GUM_SCALAR > & )

copy operator

References BNLearner().

Here is the call graph for this function:

◆ periodSize()

INLINE Size gum::learning::IBNLearner::periodSize ( ) const
overridevirtualinherited

how many samples between 2 stopping isEnableds

Exceptions
OutOfBoundsif p<1

Implements gum::IApproximationSchemeConfiguration.

Definition at line 967 of file IBNLearner_inl.h.

967 {
968 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->periodSize();
969 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
970 }
Size periodSize() const override
Returns the period size.

References currentAlgorithm_, GUM_ERROR, and gum::ApproximationScheme::periodSize().

Referenced by createPrior_().

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

◆ preferredAlgo()

IBNLearner::AlgoType gum::learning::IBNLearner::preferredAlgo ( )
staticinherited

the algorithm used by the learners when none is selected explicitly

It is read from the configuration key "learning" / "BNLearnerPreferredAlgo". A learner takes it when it is constructed and does not follow later changes of the configuration. K2 cannot be the preferred algorithm since it requires an order.

Exceptions
InvalidArgumentif the configured name is not a known algorithm

Definition at line 910 of file IBNLearner.cpp.

910 {
911 const auto name = gum::config().typed< std::string >("learning", "BNLearnerPreferredAlgo");
912 if (name == "MIIC") return AlgoType::MIIC;
913 if (name == "PC") return AlgoType::PC;
914 if (name == "FCI") return AlgoType::FCI;
915 if (name == "GreedyHillClimbing") return AlgoType::GREEDY_HILL_CLIMBING;
916 if (name == "ExtendedGreedyHillClimbing") return AlgoType::EXTENDED_GREEDY_HILL_CLIMBING;
917 if (name == "LocalSearchWithTabuList") return AlgoType::LOCAL_SEARCH_WITH_TABU_LIST;
918 if (name == "GreedyThickThinning") return AlgoType::GREEDY_THICK_THINNING;
919 GUM_ERROR(InvalidArgument,
920 "'" << name << "' is not a valid value for learning.BNLearnerPreferredAlgo")
921 }
T typed(std::string_view section, std::string_view key) const
Value of section.key converted according to its declared type.
Configuration & config()
A short name for Configuration::instance() : gum::config().epsilonStandard(). It is not inline so tha...

References gum::config(), EXTENDED_GREEDY_HILL_CLIMBING, FCI, GREEDY_HILL_CLIMBING, GREEDY_THICK_THINNING, GUM_ERROR, LOCAL_SEARCH_WITH_TABU_LIST, MIIC, PC, and gum::Configuration::typed().

Here is the call graph for this function:

◆ prepareFCI_()

MixedGraph gum::learning::IBNLearner::prepareFCI_ ( )
protectedinherited

prepares the initial graph and independence test for FCI

Definition at line 820 of file IBNLearner.cpp.

820 {
821 MixedGraph mgraph;
822 DiGraph forbiddenGraph;
823 DAG mandatoryGraph;
824
825 for (Size i = 0; i < scoreDatabase_.databaseTable().nbVariables(); ++i) {
826 mgraph.addNodeWithId(i);
827 forbiddenGraph.addNodeWithId(i);
828 mandatoryGraph.addNodeWithId(i);
829 }
830
831 const EdgeSet& possible_edges = constraintPossibleEdges_.edges();
832 if (possible_edges.empty()) {
833 for (const NodeId i: mgraph.nodes()) {
834 for (NodeId j = 0; j < i; ++j) {
835 mgraph.addEdge(j, i);
836 }
837 }
838 } else {
839 for (const auto& edge: possible_edges) {
840 mgraph.addEdge(edge.first(), edge.second());
841 }
842 }
843
844 for (const auto& arc: constraintMandatoryArcs_.arcs()) {
845 mandatoryGraph.addArc(arc.tail(), arc.head());
846 forbiddenGraph.addArc(arc.head(), arc.tail());
847 }
848 for (const auto& arc: constraintForbiddenArcs_.arcs()) {
849 forbiddenGraph.addArc(arc.tail(), arc.head());
850 }
851
853 gum::NodeProperty< gum::Size > copyOrder = gum::HashTable(sliceOrder);
854 for (const auto& [n1, r1]: sliceOrder) {
855 for (const auto& [n2, r2]: copyOrder) {
856 if (r1 > r2) {
857 forbiddenGraph.addArc(n1, n2);
858 } else if (r2 > r1) {
859 forbiddenGraph.addArc(n2, n1);
860 }
861 }
862 copyOrder.erase(n1);
863 }
864
865 const auto& totalOrder = constraintTotalOrder_.totalOrder();
866 for (auto iter1 = totalOrder.begin(); iter1 != totalOrder.end(); ++iter1) {
867 for (auto iter2 = iter1 + 1; iter2 != totalOrder.end(); ++iter2) {
868 forbiddenGraph.addArc(*iter2, *iter1);
869 }
870 }
871
872 for (const auto node: constraintNoParentNodes_.nodes()) {
873 for (const auto node2: mgraph.nodes()) {
874 if (node != node2) { forbiddenGraph.addArc(node2, node); }
875 }
876 }
877 for (const auto node: constraintNoChildrenNodes_.nodes()) {
878 for (const auto node2: mgraph.nodes()) {
879 if (node != node2) { forbiddenGraph.addArc(node, node2); }
880 }
881 }
882
883 if (indepTestFCI_) {
884 delete indepTestFCI_;
885 indepTestFCI_ = nullptr;
886 }
889 *noPrior_,
890 ranges_,
892 } else {
894 *noPrior_,
895 ranges_,
897 }
898
900 algoFCI_.setMandatoryGraph(mandatoryGraph);
901 algoFCI_.setForbiddenGraph(forbiddenGraph);
906
907 return mgraph;
908 }
void setAlpha(double alpha)
maximum conditioning set size; Size(-1) = unlimited (default)
void setIndependenceTest(IndependenceTest &test)
inject independence test (non-owning: caller manages lifetime)
void setExhaustiveSepSet(bool exhaustive)
exhaustive sepset mode: accumulate union of all separating sets found at each depth,...
void setMandatoryGraph(const gum::DAG &mandaGraph)
void setForbiddenGraph(const gum::DiGraph &forbidGraph)
void setMaxPathLength(Size maxLen)
maximum path length for R4 discriminating-path search; Size(-1) = unlimited
Definition FCI.cpp:82
IndepTestType indepTestTypeFCI_
independence test type for FCI (reuses IndepTestType defined above)
double alphaFci_
FCI parameters the threshold of the tests ; it is initialized from the key learning....
IndependenceTest * indepTestFCI_
owned independence test object for FCI (rebuilt before each learn call)
IndepTestChi2(const DBRowGeneratorParser &parser, const Prior &external_prior, const std::vector< std::pair< std::size_t, std::size_t > > &ranges, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
IndepTestG2(const DBRowGeneratorParser &parser, const Prior &external_prior, const std::vector< std::pair< std::size_t, std::size_t > > &ranges, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
Size maxIndegree() const
sets the default max indegree for all the nodes in the property
const NodeSet & nodes() const
returns the set of w nodes without children
const NodeSet & nodes() const
returns the set of nodes without parent
const EdgeSet & edges() const
returns the set of mandatory arcs
const NodeProperty< NodeId > & sliceOrder() const
returns the current slice order
const Sequence< NodeId > & totalOrder() const
returns the current Total order
Set< Edge > EdgeSet
Some typdefs and define for shortcuts ...
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.

References gum::learning::IndepTestChi2::IndepTestChi2(), gum::learning::IndepTestG2::IndepTestG2(), gum::DAG::addArc(), gum::DiGraph::addArc(), gum::UndiGraph::addEdge(), gum::NodeGraphPart::addNodeWithId(), algoFCI_, alphaFci_, gum::learning::StructuralConstraintForbiddenArcs::arcs(), gum::learning::StructuralConstraintMandatoryArcs::arcs(), Chi2, constraintForbiddenArcs_, constraintIndegree_, constraintMandatoryArcs_, constraintNoChildrenNodes_, constraintNoParentNodes_, constraintPossibleEdges_, constraintSliceOrder_, constraintTotalOrder_, gum::learning::IBNLearner::Database::databaseTable(), gum::learning::StructuralConstraintPossibleEdges::edges(), gum::Set< Key >::empty(), exhaustiveSepSetFci_, indepTestFCI_, indepTestTypeFCI_, gum::learning::StructuralConstraintIndegree::maxIndegree(), maxPathLengthFci_, gum::learning::IBNLearner::Database::nodeId2Columns(), gum::learning::StructuralConstraintNoChildrenNodes::nodes(), gum::learning::StructuralConstraintNoParentNodes::nodes(), gum::NodeGraphPart::nodes(), noPrior_, gum::learning::IBNLearner::Database::parser(), ranges_, scoreDatabase_, gum::learning::CIBasedLearning::setAlpha(), gum::learning::CIBasedLearning::setExhaustiveSepSet(), gum::learning::ConstraintBasedLearning::setForbiddenGraph(), gum::learning::CIBasedLearning::setIndependenceTest(), gum::learning::ConstraintBasedLearning::setMandatoryGraph(), gum::learning::ConstraintBasedLearning::setMaxIndegree(), gum::learning::FCI::setMaxPathLength(), gum::learning::StructuralConstraintSliceOrder::sliceOrder(), and gum::learning::StructuralConstraintTotalOrder::totalOrder().

Referenced by createPrior_(), learnDag_(), learnPAG_(), and learnPDAG_().

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

◆ prepareMiic_()

MixedGraph gum::learning::IBNLearner::prepareMiic_ ( )
protectedinherited

prepares the initial graph for miic

Definition at line 628 of file IBNLearner.cpp.

628 {
629 // Initialize the mixed graph to the fully connected graph
630 MixedGraph mgraph;
631 DiGraph forbiddenGraph;
632 DAG mandatoryGraph;
633
634 // GUM_CHECKPOINT
635 for (Size i = 0; i < scoreDatabase_.databaseTable().nbVariables(); ++i) {
636 mgraph.addNodeWithId(i);
637 forbiddenGraph.addNodeWithId(i);
638 mandatoryGraph.addNodeWithId(i);
639 }
640
641 const EdgeSet& possible_edges = constraintPossibleEdges_.edges();
642
643 if (possible_edges.empty()) {
644 for (const NodeId i: mgraph.nodes()) {
645 for (NodeId j = 0; j < i; ++j) {
646 // contiguous nodeIds !
647 mgraph.addEdge(j, i);
648 }
649 }
650 } else {
651 for (const auto& edge: possible_edges) {
652 mgraph.addEdge(edge.first(), edge.second());
653 }
654 }
655 // GUM_CHECKPOINT
656
657 // translating the mandatory arcs for constraintMiic
658 HashTable< std::pair< NodeId, NodeId >, char > initial_marks;
659 const ArcSet& mandatory_arcs = constraintMandatoryArcs_.arcs();
660
661 // GUM_CHECKPOINT
662 for (const auto& arc: mandatory_arcs) {
663 mandatoryGraph.addArc(arc.tail(), arc.head());
664 // MIIC's marks mechanism (orientationMiic_) handles the reverse direction;
665 // adding it to forbiddenGraph would cause DuplicateElement (unlike preparePC_).
666 }
667
668 // GUM_CHECKPOINT
669 // translating the forbidden arcs for constraintMiic
670 const ArcSet& forbidden_arcs = constraintForbiddenArcs_.arcs();
671 for (const auto& arc: forbidden_arcs) {
672 forbiddenGraph.addArc(arc.tail(), arc.head());
673 }
674
675 // GUM_CHECKPOINT
677 gum::NodeProperty< gum::Size > copyOrder = gum::HashTable(sliceOrder);
678 for (const auto& [n1, r1]: sliceOrder) {
679 for (const auto& [n2, r2]: copyOrder) {
680 if (r1 > r2) {
681 forbiddenGraph.addArc(n1, n2);
682 // initial_marks.insert({n1, n2}, '-');
683 } else if (r2 > r1) {
684 forbiddenGraph.addArc(n2, n1);
685 // initial_marks.insert({n2, n1}, '-');
686 }
687 }
688 copyOrder.erase(n1);
689 }
690
691 // GUM_CHECKPOINT
692 const auto& totalOrder = constraintTotalOrder_.totalOrder();
693 for (auto iter1 = totalOrder.begin(); iter1 != totalOrder.end(); ++iter1) {
694 const auto node1 = *iter1;
695 for (auto iter2 = iter1 + 1; iter2 != totalOrder.end(); ++iter2) {
696 forbiddenGraph.addArc(*iter2, node1);
697 }
698 }
699
700 for (const auto node: constraintNoParentNodes_.nodes()) {
701 for (const auto node2: mgraph.nodes()) {
702 if (node != node2) { forbiddenGraph.addArc(node2, node); }
703 }
704 }
705
706 for (const auto node: constraintNoChildrenNodes_.nodes()) {
707 for (const auto node2: mgraph.nodes()) {
708 if (node != node2) { forbiddenGraph.addArc(node, node2); }
709 }
710 }
711
712 // GUM_CHECKPOINT
714 algoMiic_.addConstraints(initial_marks);
715 algoMiic_.setMandatoryGraph(mandatoryGraph);
716 algoMiic_.setForbiddenGraph(forbiddenGraph);
717
718 // GUM_CHECKPOINT
719 // create the mutual entropy object
720 // if ( _mutual_info_ == nullptr) { this->useNMLCorrection(); }
722
723 // GUM_CHECKPOINT
724 return mgraph;
725 }
void addConstraints(const HashTable< std::pair< NodeId, NodeId >, char > &constraints)
void createCorrectedMutualInformation_()
create the Corrected Mutual Information instance for Miic

References gum::DAG::addArc(), gum::DiGraph::addArc(), gum::learning::ConstraintBasedLearning::addConstraints(), gum::UndiGraph::addEdge(), gum::NodeGraphPart::addNodeWithId(), algoMiic_, gum::learning::StructuralConstraintForbiddenArcs::arcs(), gum::learning::StructuralConstraintMandatoryArcs::arcs(), constraintForbiddenArcs_, constraintIndegree_, constraintMandatoryArcs_, constraintNoChildrenNodes_, constraintNoParentNodes_, constraintPossibleEdges_, constraintSliceOrder_, constraintTotalOrder_, createCorrectedMutualInformation_(), gum::learning::IBNLearner::Database::databaseTable(), gum::learning::StructuralConstraintPossibleEdges::edges(), gum::Set< Key >::empty(), gum::learning::StructuralConstraintIndegree::maxIndegree(), gum::learning::StructuralConstraintNoChildrenNodes::nodes(), gum::learning::StructuralConstraintNoParentNodes::nodes(), gum::NodeGraphPart::nodes(), scoreDatabase_, gum::learning::ConstraintBasedLearning::setForbiddenGraph(), gum::learning::ConstraintBasedLearning::setMandatoryGraph(), gum::learning::ConstraintBasedLearning::setMaxIndegree(), gum::learning::StructuralConstraintSliceOrder::sliceOrder(), and gum::learning::StructuralConstraintTotalOrder::totalOrder().

Referenced by createPrior_(), learnDag_(), and learnPDAG_().

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

◆ preparePC_()

MixedGraph gum::learning::IBNLearner::preparePC_ ( )
protectedinherited

prepares the initial graph and independence test for PC

Definition at line 727 of file IBNLearner.cpp.

727 {
728 MixedGraph mgraph;
729 DiGraph forbiddenGraph;
730 DAG mandatoryGraph;
731
732 for (Size i = 0; i < scoreDatabase_.databaseTable().nbVariables(); ++i) {
733 mgraph.addNodeWithId(i);
734 forbiddenGraph.addNodeWithId(i);
735 mandatoryGraph.addNodeWithId(i);
736 }
737
738 const EdgeSet& possible_edges = constraintPossibleEdges_.edges();
739 if (possible_edges.empty()) {
740 for (const NodeId i: mgraph.nodes()) {
741 for (NodeId j = 0; j < i; ++j) {
742 mgraph.addEdge(j, i);
743 }
744 }
745 } else {
746 for (const auto& edge: possible_edges) {
747 mgraph.addEdge(edge.first(), edge.second());
748 }
749 }
750
751 for (const auto& arc: constraintMandatoryArcs_.arcs()) {
752 mandatoryGraph.addArc(arc.tail(), arc.head());
753 forbiddenGraph.addArc(arc.head(), arc.tail());
754 }
755 for (const auto& arc: constraintForbiddenArcs_.arcs()) {
756 forbiddenGraph.addArc(arc.tail(), arc.head());
757 }
758
760 gum::NodeProperty< gum::Size > copyOrder = gum::HashTable(sliceOrder);
761 for (const auto& [n1, r1]: sliceOrder) {
762 for (const auto& [n2, r2]: copyOrder) {
763 if (r1 > r2) {
764 forbiddenGraph.addArc(n1, n2);
765 } else if (r2 > r1) {
766 forbiddenGraph.addArc(n2, n1);
767 }
768 }
769 copyOrder.erase(n1);
770 }
771
772 const auto& totalOrder = constraintTotalOrder_.totalOrder();
773 for (auto iter1 = totalOrder.begin(); iter1 != totalOrder.end(); ++iter1) {
774 for (auto iter2 = iter1 + 1; iter2 != totalOrder.end(); ++iter2) {
775 forbiddenGraph.addArc(*iter2, *iter1);
776 }
777 }
778
779 for (const auto node: constraintNoParentNodes_.nodes()) {
780 for (const auto node2: mgraph.nodes()) {
781 if (node != node2) { forbiddenGraph.addArc(node2, node); }
782 }
783 }
784 for (const auto node: constraintNoChildrenNodes_.nodes()) {
785 for (const auto node2: mgraph.nodes()) {
786 if (node != node2) { forbiddenGraph.addArc(node, node2); }
787 }
788 }
789
790 // build the independence test (owned by IBNLearner)
791 if (indepTestPC_) {
792 delete indepTestPC_;
793 indepTestPC_ = nullptr;
794 }
797 *noPrior_,
798 ranges_,
800 } else {
802 *noPrior_,
803 ranges_,
805 }
806
808 algoPC_.setMandatoryGraph(mandatoryGraph);
809 algoPC_.setForbiddenGraph(forbiddenGraph);
816
817 return mgraph;
818 }
void setUCPriority(UCPriority p)
collider candidate ordering (default: Standard)
@ Sorted
descending p-value order (strongest evidence first)
@ Standard
process triples in natural traversal order
void setMaxCondSetSize(Size max_k)
maximum conditioning set size; Size(-1) = unlimited (default)
void setStable(bool stable)
stable mode: defer edge removals until end of each depth (default: true)
IndependenceTest * indepTestPC_
owned independence test object for PC (rebuilt before each learn call)
double alphaPc_
PC parameters the threshold of the tests ; it is initialized from the key learning....
IndepTestType indepTestTypePC_

References gum::learning::IndepTestChi2::IndepTestChi2(), gum::learning::IndepTestG2::IndepTestG2(), gum::DAG::addArc(), gum::DiGraph::addArc(), gum::UndiGraph::addEdge(), gum::NodeGraphPart::addNodeWithId(), algoPC_, alphaPc_, gum::learning::StructuralConstraintForbiddenArcs::arcs(), gum::learning::StructuralConstraintMandatoryArcs::arcs(), Chi2, constraintForbiddenArcs_, constraintIndegree_, constraintMandatoryArcs_, constraintNoChildrenNodes_, constraintNoParentNodes_, constraintPossibleEdges_, constraintSliceOrder_, constraintTotalOrder_, gum::learning::IBNLearner::Database::databaseTable(), gum::learning::StructuralConstraintPossibleEdges::edges(), gum::Set< Key >::empty(), indepTestPC_, indepTestTypePC_, maxCondSetSizePc_, gum::learning::StructuralConstraintIndegree::maxIndegree(), gum::learning::IBNLearner::Database::nodeId2Columns(), gum::learning::StructuralConstraintNoChildrenNodes::nodes(), gum::learning::StructuralConstraintNoParentNodes::nodes(), gum::NodeGraphPart::nodes(), noPrior_, gum::learning::IBNLearner::Database::parser(), ranges_, scoreDatabase_, gum::learning::CIBasedLearning::setAlpha(), gum::learning::ConstraintBasedLearning::setForbiddenGraph(), gum::learning::CIBasedLearning::setIndependenceTest(), gum::learning::ConstraintBasedLearning::setMandatoryGraph(), gum::learning::CIBasedLearning::setMaxCondSetSize(), gum::learning::ConstraintBasedLearning::setMaxIndegree(), gum::learning::CIBasedLearning::setStable(), gum::learning::CIBasedLearning::setUCPriority(), gum::learning::StructuralConstraintSliceOrder::sliceOrder(), gum::learning::CIBasedLearning::Sorted, sortedUCPc_, stablePc_, gum::learning::CIBasedLearning::Standard, and gum::learning::StructuralConstraintTotalOrder::totalOrder().

Referenced by createPrior_(), learnDag_(), and learnPDAG_().

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

◆ rawPseudoCount() [1/2]

std::vector< double > gum::learning::IBNLearner::rawPseudoCount ( const std::vector< NodeId > & vars)
inherited

Return the pseudo-counts of NodeIds vars in the base in a raw array.

Parameters
varsa vector of
Returns
a std::vector<double> containing the contingency table

Definition at line 1511 of file IBNLearner.cpp.

1511 {
1512 if (this->hasMissingValues()) {
1513 GUM_ERROR(MissingValueInDatabase,
1514 "BNLearner cannot compute pseudo-counts with missing values in the database")
1515 }
1516 if (vars.empty()) {
1517 GUM_ERROR(OutOfBounds, "BNLearner::rawPseudoCount called with an empty vector of variables")
1518 }
1519 Tensor< double > res;
1520
1521 createPrior_();
1522 gum::learning::PseudoCount count(scoreDatabase_.parser(), *prior_, databaseRanges());
1523 return count.get(vars);
1524 }
bool hasMissingValues() const
returns true if the learner's database has missing values
template class GUM_SHARED_PUBLIC Tensor< double >
Definition tensor.cpp:53

References createPrior_(), databaseRanges(), gum::learning::PseudoCount::get(), GUM_ERROR, hasMissingValues(), gum::learning::IBNLearner::Database::parser(), prior_, scoreDatabase_, and gum::Tensor< double >.

Referenced by rawPseudoCount().

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

◆ rawPseudoCount() [2/2]

std::vector< double > gum::learning::IBNLearner::rawPseudoCount ( const std::vector< std::string > & vars)
inherited

Return the pseudoconts of vars in the base in a raw array.

Parameters
varsa vector of name
Returns
a std::vector<double> containing the contingency table

Definition at line 1526 of file IBNLearner.cpp.

1526 {
1527 std::vector< NodeId > ids;
1528
1529 auto mapper = [this](const std::string& c) { return this->idFromName(c); };
1530
1531 std::transform(vars.begin(), vars.end(), std::back_inserter(ids), mapper);
1532 return rawPseudoCount(ids);
1533 }
std::vector< double > rawPseudoCount(const std::vector< NodeId > &vars)
Return the pseudo-counts of NodeIds vars in the base in a raw array.

References idFromName(), and rawPseudoCount().

Here is the call graph for this function:

◆ readFile_()

DatabaseTable gum::learning::IBNLearner::readFile_ ( std::string_view filename,
const std::vector< std::string > & missing_symbols )
staticprotectedinherited

reads a file and returns a databaseVectInRam

Definition at line 491 of file IBNLearner.cpp.

492 {
493 // get the extension of the file
494 isCSVFileName_(filename);
495
496 DBInitializerFromCSV initializer{std::string(filename)};
497
498 const auto& var_names = initializer.variableNames();
499 const std::size_t nb_vars = var_names.size();
500
501 DBTranslatorSet translator_set;
502 DBTranslator4LabelizedVariable translator(missing_symbols);
503 for (std::size_t i = 0; i < nb_vars; ++i) {
504 translator_set.insertTranslator(translator, i);
505 }
506
507 DatabaseTable database(missing_symbols, translator_set);
508 database.setVariableNames(initializer.variableNames());
509 initializer.fillDatabase(database);
510
512
513 return database;
514 }
void setVariableNames(const std::vector< std::string > &names, const bool from_external_object=true) override
sets the names of the variables
void reorder(const std::size_t k, const bool k_is_input_col=false)
performs a reordering of the kth translator or of the first translator parsing the kth column of the ...
static void isCSVFileName_(std::string_view filename)
checks whether the extension of a CSV filename is correct
const DatabaseTable & database() const
returns the database used by the BNLearner

References database(), gum::learning::IDBInitializer::fillDatabase(), gum::learning::DBTranslatorSet::insertTranslator(), isCSVFileName_(), gum::learning::DatabaseTable::reorder(), gum::learning::DatabaseTable::setVariableNames(), and gum::learning::IDBInitializer::variableNames().

Referenced by gum::learning::IBNLearner::Database::Database().

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

◆ recordWeight()

INLINE double gum::learning::IBNLearner::recordWeight ( const std::size_t i) const
inherited

returns the weight of the ith record

Exceptions
OutOfBoundsif i is outside the set of indices of the records

Definition at line 157 of file IBNLearner_inl.h.

157 {
158 return scoreDatabase_.weight(i);
159 }

References scoreDatabase_, and gum::learning::IBNLearner::Database::weight().

Here is the call graph for this function:

◆ score() [1/2]

double gum::learning::IBNLearner::score ( NodeId vars,
const std::vector< NodeId > & knowing = {} )
inherited

Return the value of the score currently in use by the BNLearner of a variable given a set of other variables.

Parameters
varthe NodeId of the LHS variable
knowingan optional vector of conditioning variables, specified by their NodeIds
Returns
a double corresponding to the value of the score

Definition at line 1493 of file IBNLearner.cpp.

1493 {
1494 createPrior_();
1495 createScore_();
1496
1497 return score_->score(var, knowing);
1498 }
double score(const NodeId var)
returns the score of a single node

References createPrior_(), createScore_(), gum::learning::Score::score(), and score_.

Referenced by score(), and useDatabaseRanges().

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

◆ score() [2/2]

double gum::learning::IBNLearner::score ( std::string_view vars,
const std::vector< std::string > & knowing = {} )
inherited

Return the value of the score currently in use by the BNLearner of a variable given a set of other variables The score used is the one currently selected in the BNLearner.

Parameters
varthe name of the variable
knowingan optional vector of conditioning variables, specified by their names
Returns
a double corresponding to the value of the score

Definition at line 1500 of file IBNLearner.cpp.

1500 {
1501 auto mapper = [this](const std::string& c) { return this->idFromName(c); };
1502
1503 const NodeId id = this->idFromName(var);
1504 std::vector< NodeId > knowingIds;
1505 knowingIds.reserve(knowing.size());
1506 std::transform(knowing.begin(), knowing.end(), std::back_inserter(knowingIds), mapper);
1507
1508 return score(id, knowingIds);
1509 }
double score(NodeId vars, const std::vector< NodeId > &knowing={})
Return the value of the score currently in use by the BNLearner of a variable given a set of other va...

References idFromName(), and score().

Here is the call graph for this function:

◆ setCurrentApproximationScheme()

INLINE void gum::learning::IBNLearner::setCurrentApproximationScheme ( const ApproximationScheme * approximationScheme)
inherited

{@ /// distribute signals

Definition at line 813 of file IBNLearner_inl.h.

813 {
814 currentAlgorithm_ = approximationScheme;
815 }

References currentAlgorithm_.

Referenced by gum::learning::BNLearnerListener::BNLearnerListener(), createPrior_(), distributeProgress(), and distributeStop().

Here is the caller graph for this function:

◆ setDatabaseWeight()

INLINE void gum::learning::IBNLearner::setDatabaseWeight ( const double new_weight)
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 147 of file IBNLearner_inl.h.

147 {
149 }
void setDatabaseWeight(const double new_weight)
assign a weight to all the rows of the database so that the sum of their weights is equal to new_weig...

References scoreDatabase_, and gum::learning::IBNLearner::Database::setDatabaseWeight().

Here is the call graph for this function:

◆ setEpsilon()

INLINE void gum::learning::IBNLearner::setEpsilon ( double eps)
overridevirtualinherited

Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)| If the criterion was disabled it will be enabled.

Exceptions
OutOfBoundsif eps<0

Implements gum::IApproximationSchemeConfiguration.

Definition at line 831 of file IBNLearner_inl.h.

831 {
835 dag2BN_.setEpsilon(eps);
836 }
void setEpsilon(double eps) override
Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)|.
void setEpsilon(double eps) override
sets the stopping criterion of EM as being the minimal difference between two consecutive log-likelih...

References algoK2_, gum::learning::K2::approximationScheme(), dag2BN_, greedyHillClimbing_, localSearchWithTabuList_, gum::ApproximationScheme::setEpsilon(), and gum::learning::EMApproximationScheme::setEpsilon().

Referenced by createPrior_().

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

◆ setFCIAlpha()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setFCIAlpha ( double alpha)

References BNLearner(), and setFCIAlpha().

Referenced by setFCIAlpha().

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

◆ setFCIExhaustiveSepSet()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setFCIExhaustiveSepSet ( bool exhaustive)

References BNLearner(), and setFCIExhaustiveSepSet().

Referenced by setFCIExhaustiveSepSet().

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

◆ setFCIMaxPathLength()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setFCIMaxPathLength ( Size max_len)

References BNLearner(), and setFCIMaxPathLength().

Referenced by setFCIMaxPathLength().

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

◆ setForbiddenArcs()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setForbiddenArcs ( const ArcSet & set)

References BNLearner(), and setForbiddenArcs().

Referenced by setForbiddenArcs().

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

◆ setGreedyThickThinningReversals()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setGreedyThickThinningReversals ( bool allow)

References BNLearner(), and setGreedyThickThinningReversals().

Referenced by setGreedyThickThinningReversals().

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

◆ setInitialDAG()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setInitialDAG ( const DAG & dag)

References BNLearner(), and setInitialDAG().

Referenced by setInitialDAG().

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

◆ setMandatoryArcs()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setMandatoryArcs ( const ArcSet & set)

References BNLearner(), and setMandatoryArcs().

Referenced by setMandatoryArcs().

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

◆ setMaxIndegree()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setMaxIndegree ( Size max_indegree)

References BNLearner(), and setMaxIndegree().

Referenced by setMaxIndegree().

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

◆ setMaxIter()

INLINE void gum::learning::IBNLearner::setMaxIter ( Size max)
overridevirtualinherited

stopping criterion on number of iterationsIf the criterion was disabled it will be enabled

Parameters
maxThe maximum number of iterations
Exceptions
OutOfBoundsif max<=1

Implements gum::IApproximationSchemeConfiguration.

Definition at line 893 of file IBNLearner_inl.h.

893 {
897 dag2BN_.setMaxIter(max);
898 }
void setMaxIter(Size max) override
Stopping criterion on number of iterations.

References algoK2_, gum::learning::K2::approximationScheme(), dag2BN_, greedyHillClimbing_, localSearchWithTabuList_, and gum::ApproximationScheme::setMaxIter().

Referenced by createPrior_().

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

◆ setMaxTime()

INLINE void gum::learning::IBNLearner::setMaxTime ( double timeout)
overridevirtualinherited

stopping criterion on timeout If the criterion was disabled it will be enabled

Exceptions
OutOfBoundsif timeout<=0.0 timeout is time in second (double).

Implements gum::IApproximationSchemeConfiguration.

Definition at line 924 of file IBNLearner_inl.h.

924 {
928 dag2BN_.setMaxTime(timeout);
929 }
void setMaxTime(double timeout) override
Stopping criterion on timeout.

References algoK2_, gum::learning::K2::approximationScheme(), dag2BN_, greedyHillClimbing_, localSearchWithTabuList_, and gum::ApproximationScheme::setMaxTime().

Referenced by createPrior_().

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

◆ setMinEpsilonRate()

INLINE void gum::learning::IBNLearner::setMinEpsilonRate ( double rate)
overridevirtualinherited

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.

Exceptions
OutOfBoundsif rate<0

Implements gum::IApproximationSchemeConfiguration.

Definition at line 862 of file IBNLearner_inl.h.

862 {
867 }
void setMinEpsilonRate(double rate) override
Given that we approximate f(t), stopping criterion on d/dt(|f(t+1)-f(t)|).
void setMinEpsilonRate(double rate) override
sets the stopping criterion of EM as being the minimal log-likelihood's evolution rate

References algoK2_, gum::learning::K2::approximationScheme(), dag2BN_, greedyHillClimbing_, localSearchWithTabuList_, gum::ApproximationScheme::setMinEpsilonRate(), and gum::learning::EMApproximationScheme::setMinEpsilonRate().

Referenced by createPrior_().

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

◆ setNumberOfThreads()

INLINE void gum::learning::IBNLearner::setNumberOfThreads ( Size nb)
overridevirtualinherited

sets the number max of threads that can be used

Parameters
nbthe number max of threads to be used. If this number is set to 0, then it is defaulted to aGrUM's max number of threads

Implements gum::IThreadNumberManager.

Definition at line 787 of file IBNLearner_inl.h.

787 {
789 if (score_ != nullptr) score_->setNumberOfThreads(nb);
790 }
void setNumberOfThreads(Size nb) override
sets the number max of threads to be used by the class containing this ThreadNumberManager

References score_, gum::learning::Score::setNumberOfThreads(), and gum::ThreadNumberManager::setNumberOfThreads().

Here is the call graph for this function:

◆ setPCAlpha()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setPCAlpha ( double alpha)

References BNLearner(), and setPCAlpha().

Referenced by setPCAlpha().

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

◆ setPCMaxCondSetSize()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setPCMaxCondSetSize ( Size max_k)

References BNLearner(), and setPCMaxCondSetSize().

Referenced by setPCMaxCondSetSize().

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

◆ setPCStable()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setPCStable ( bool stable)

References BNLearner(), and setPCStable().

Referenced by setPCStable().

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

◆ setPCUnshieldedColliderSorted()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setPCUnshieldedColliderSorted ( bool sorted)

References BNLearner(), and setPCUnshieldedColliderSorted().

Referenced by setPCUnshieldedColliderSorted().

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

◆ setPeriodSize()

INLINE void gum::learning::IBNLearner::setPeriodSize ( Size p)
overridevirtualinherited

how many samples between 2 stopping isEnableds

Exceptions
OutOfBoundsif p<1

Implements gum::IApproximationSchemeConfiguration.

Definition at line 960 of file IBNLearner_inl.h.

960 {
965 }
void setPeriodSize(Size p) override
How many samples between two stopping is enable.

References algoK2_, gum::learning::K2::approximationScheme(), dag2BN_, greedyHillClimbing_, localSearchWithTabuList_, and gum::ApproximationScheme::setPeriodSize().

Referenced by createPrior_().

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

◆ setPossibleEdges()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setPossibleEdges ( const EdgeSet & set)

References BNLearner(), and setPossibleEdges().

Referenced by setPossibleEdges().

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

◆ setPossibleSkeleton()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setPossibleSkeleton ( const UndiGraph & skeleton)

References BNLearner(), and setPossibleSkeleton().

Referenced by setPossibleSkeleton().

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

◆ setRecordWeight()

INLINE void gum::learning::IBNLearner::setRecordWeight ( const std::size_t i,
const double weight )
inherited

sets the weight of the ith record of the database

assign new weight to the ith row of the learning database

Exceptions
OutOfBoundsif i is outside the set of indices of the records or if the weight is negative

Definition at line 152 of file IBNLearner_inl.h.

152 {
153 scoreDatabase_.setWeight(i, new_weight);
154 }
void setWeight(const std::size_t i, const double weight)
sets the weight of the ith record

References scoreDatabase_, and gum::learning::IBNLearner::Database::setWeight().

Here is the call graph for this function:

◆ setSliceOrder() [1/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setSliceOrder ( const NodeProperty< NodeId > & slice_order)

References BNLearner(), and setSliceOrder().

Referenced by setSliceOrder(), and setSliceOrder().

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

◆ setSliceOrder() [2/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setSliceOrder ( const std::vector< std::vector< std::string > > & slices)

References BNLearner(), and setSliceOrder().

Here is the call graph for this function:

◆ setTotalOrder() [1/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setTotalOrder ( const Sequence< NodeId > & order)

References BNLearner(), and setTotalOrder().

Here is the call graph for this function:

◆ setTotalOrder() [2/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::setTotalOrder ( const std::vector< std::string > & order)

References BNLearner(), and setTotalOrder().

Referenced by setTotalOrder(), and setTotalOrder().

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

◆ setVerbosity()

INLINE void gum::learning::IBNLearner::setVerbosity ( bool v)
overridevirtualinherited

verbosity

Implements gum::IApproximationSchemeConfiguration.

Definition at line 972 of file IBNLearner_inl.h.

972 {
977 }
void setVerbosity(bool v) override
Set the verbosity on (true) or off (false).

References algoK2_, gum::learning::K2::approximationScheme(), dag2BN_, greedyHillClimbing_, localSearchWithTabuList_, and gum::ApproximationScheme::setVerbosity().

Referenced by createPrior_().

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

◆ state()

template<GUM_Numeric GUM_SCALAR>
std::vector< std::tuple< std::string, std::string, std::string > > gum::learning::BNLearner< GUM_SCALAR >::state ( ) const
Returns
a representation of the state of the learner in the form vector<key,value,comment>

References state().

Referenced by state().

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

◆ stateApproximationScheme()

INLINE IApproximationSchemeConfiguration::ApproximationSchemeSTATE gum::learning::IBNLearner::stateApproximationScheme ( ) const
overridevirtualinherited

history

Implements gum::IApproximationSchemeConfiguration.

Definition at line 985 of file IBNLearner_inl.h.

985 {
987 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
988 }

References currentAlgorithm_, GUM_ERROR, and gum::ApproximationScheme::stateApproximationScheme().

Referenced by createPrior_().

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

◆ toString()

template<GUM_Numeric GUM_SCALAR>
std::string gum::learning::BNLearner< GUM_SCALAR >::toString ( ) const
Returns
Returns a string representation of this BNLearner's current features.

References toString().

Referenced by toString().

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

◆ unsetSliceOrder()

INLINE void gum::learning::IBNLearner::unsetSliceOrder ( )
inherited

removes the slice order constraint

The methd is useful if you had previously added a slice order constraint and you do not want to use it anymore

Definition at line 655 of file IBNLearner_inl.h.

void setSliceOrder(const NodeProperty< NodeId > &slice_order)
sets a partial order on the nodes

References setSliceOrder().

Here is the call graph for this function:

◆ unsetTotalOrder()

INLINE void gum::learning::IBNLearner::unsetTotalOrder ( )
inherited

removes the current total ordering constraint, if any

Definition at line 672 of file IBNLearner_inl.h.

672{ setTotalOrder(Sequence< NodeId >()); }
void setTotalOrder(const Sequence< NodeId > &order)
sets a total order over some nodes

References setTotalOrder().

Here is the call graph for this function:

◆ useBDeuPrior() [1/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useBDeuPrior ( )

use the BDeu prior with the default weight (key priorWeight of the section learning)

References BNLearner(), and useBDeuPrior().

Here is the call graph for this function:

◆ useBDeuPrior() [2/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useBDeuPrior ( double weight)

References BNLearner(), and useBDeuPrior().

Referenced by useBDeuPrior(), and useBDeuPrior().

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

◆ useChi2Test()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useChi2Test ( )

References BNLearner(), and useChi2Test().

Referenced by useChi2Test().

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

◆ useCrossValidationFold()

std::pair< std::size_t, std::size_t > gum::learning::IBNLearner::useCrossValidationFold ( const std::size_t learning_fold,
const std::size_t k_fold )
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).

Parameters
learning_folda 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_foldthe value of "k" in k-fold cross validation
Returns
a pair [x,y) of rows' indices that corresponds to the indices of rows in the original database that constitute the test dataset
Exceptions
OutOfBoundsis 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 1329 of file IBNLearner.cpp.

1330 {
1331 if (k_fold == 0) { GUM_ERROR(OutOfBounds, "K-fold cross validation with k=0 is forbidden") }
1332
1333 if (learning_fold >= k_fold) {
1334 GUM_ERROR(OutOfBounds,
1335 "In " << k_fold << "-fold cross validation, the learning "
1336 << "fold should be strictly lower than " << k_fold
1337 << " but, here, it is equal to " << learning_fold)
1338 }
1339
1340 const std::size_t db_size = scoreDatabase_.databaseTable().nbRows();
1341 if (k_fold >= db_size) {
1342 GUM_ERROR(OutOfBounds,
1343 "In " << k_fold << "-fold cross validation, the database's "
1344 << "size should be strictly greater than " << k_fold
1345 << " but, here, the database has only " << db_size << "rows")
1346 }
1347
1348 // create the ranges of rows of the test database
1349 const std::size_t foldSize = db_size / k_fold;
1350 const std::size_t unfold_deb = learning_fold * foldSize;
1351 const std::size_t unfold_end = unfold_deb + foldSize;
1352
1353 ranges_.clear();
1354 if (learning_fold == std::size_t(0)) {
1355 ranges_.push_back(std::pair< std::size_t, std::size_t >(unfold_end, db_size));
1356 } else {
1357 ranges_.push_back(std::pair< std::size_t, std::size_t >(std::size_t(0), unfold_deb));
1358
1359 if (learning_fold != k_fold - 1) {
1360 ranges_.push_back(std::pair< std::size_t, std::size_t >(unfold_end, db_size));
1361 }
1362 }
1363
1364 return std::pair< std::size_t, std::size_t >(unfold_deb, unfold_end);
1365 }
std::size_t nbRows() const noexcept
returns the number of records (rows) in the database

References gum::learning::IBNLearner::Database::databaseTable(), GUM_ERROR, gum::learning::IDatabaseTable< T_DATA >::nbRows(), ranges_, and scoreDatabase_.

Here is the call graph for this function:

◆ useDatabaseRanges()

void gum::learning::IBNLearner::useDatabaseRanges ( const std::vector< std::pair< std::size_t, std::size_t > > & new_ranges)
inherited

use a new set of database rows' ranges to perform learning

Parameters
rangesa 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 1536 of file IBNLearner.cpp.

1537 {
1538 // use a score to detect whether the ranges are ok
1539 ScoreLog2Likelihood score(scoreDatabase_.parser(), *noPrior_);
1540 score.setRanges(new_ranges);
1541 ranges_ = score.ranges();
1542 }

References noPrior_, gum::learning::IBNLearner::Database::parser(), gum::learning::Score::ranges(), ranges_, score(), scoreDatabase_, and gum::learning::Score::setRanges().

Here is the call graph for this function:

◆ useDirichletPrior() [1/4]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useDirichletPrior ( const gum::BayesNet< GUM_SCALAR > & bn)

use the Dirichlet prior from a BN with the default weight (key priorWeight)

References BNLearner(), and useDirichletPrior().

Here is the call graph for this function:

◆ useDirichletPrior() [2/4]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useDirichletPrior ( const gum::BayesNet< GUM_SCALAR > & bn,
double weight )

References BNLearner(), and useDirichletPrior().

Here is the call graph for this function:

◆ useDirichletPrior() [3/4]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useDirichletPrior ( std::string_view filename)

use the Dirichlet prior from a database with the default weight (key priorWeight)

References BNLearner(), and useDirichletPrior().

Here is the call graph for this function:

◆ useDirichletPrior() [4/4]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useDirichletPrior ( std::string_view filename,
double weight )

References BNLearner(), and useDirichletPrior().

Referenced by useDirichletPrior(), useDirichletPrior(), useDirichletPrior(), and useDirichletPrior().

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

◆ useEM() [1/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useEM ( const double epsilon)

use The EM algorithm to learn parameters with the default noise (key emNoise of the section learning of gum::Configuration)

References BNLearner(), gum::learning::IBNLearner::epsilon(), and useEM().

Here is the call graph for this function:

◆ useEM() [2/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useEM ( const double epsilon,
const double noise )

use The EM algorithm to learn parameters

This is essentially an alias for Method useEMWithRateCriterion().

Parameters
epsilonsets the approximation stopping criterion: EM stops whenever the absolute value of the relative difference between two consecutive log-likelihoods drops below epsilon. Note that epsilon=0 is considered as a directive to not use EM. However, if you wish to forbid the use of EM, prefer executing Method forbidEM() rather than useEM(0) as it is more unequivocal.
noiseWhen EM starts, it initializes all the CPTs of the Bayes net. EM adds a noise to these CPTs by mixing their values with some random noise. The formula used is, up to some normalizing constant: new_cpt = (1-noise) * cpt + noise * random_cpt(). Of course, noise must belong to interval [0,1].
Returns
the BNLearner (so that we can chains the calls to useXXX() methods)
Warning
if epsilon=0, EM is not used
Exceptions
OutOfBoundsis raised if epsilon is strictly negative or if noise does not belong to interval [0,1].

References BNLearner(), gum::learning::IBNLearner::epsilon(), and useEM().

Referenced by useEM(), and useEM().

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

◆ useEMWithDiffCriterion() [1/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useEMWithDiffCriterion ( const double epsilon)

use The EM algorithm with the diff stopping criterion and the default noise (key emNoise)

References BNLearner(), gum::learning::IBNLearner::epsilon(), and useEMWithDiffCriterion().

Here is the call graph for this function:

◆ useEMWithDiffCriterion() [2/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useEMWithDiffCriterion ( const double epsilon,
const double noise )

use The EM algorithm to learn parameters with the diff stopping criterion

Parameters
epsilonepsilon sets the approximation stopping criterion: EM stops whenever the difference between two consecutive log-likelihoods drops below epsilon. Note that, for using EM, epsilon should be strictly positive.
noiseWhen EM starts, it initializes all the CPTs of the Bayes net. EM adds a noise to these CPTs by mixing their values with some random noise. The formula used is, up to some normalizing constant: new_cpt = (1-noise) * cpt + noise * random_cpt(). Of course, noise must belong to interval [0,1].
Returns
the BNLearner (so that we can chains the calls to useXXX() methods)
Exceptions
OutOfBoundsis raised if epsilon is not strictly positive or if noise does not belong to interval [0,1].

References BNLearner(), gum::learning::IBNLearner::epsilon(), and useEMWithDiffCriterion().

Referenced by useEMWithDiffCriterion(), and useEMWithDiffCriterion().

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

◆ useEMWithRateCriterion() [1/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useEMWithRateCriterion ( const double epsilon)

use The EM algorithm with the rate stopping criterion and the default noise (key emNoise)

References BNLearner(), gum::learning::IBNLearner::epsilon(), and useEMWithRateCriterion().

Here is the call graph for this function:

◆ useEMWithRateCriterion() [2/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useEMWithRateCriterion ( const double epsilon,
const double noise )

use The EM algorithm to learn parameters with the rate stopping criterion

Parameters
epsilonepsilon sets the approximation stopping criterion: EM stops whenever the absolute value of the relative difference between two consecutive log-likelihoods drops below epsilon. Note that, for using EM, epsilon should be strictly positive.
max_nb_iterthe maximum number of EM iterations allowed. If equal to 0, this stopping criterion is unused.
noiseWhen EM starts, it initializes all the CPTs of the Bayes net. EM adds a noise to these CPTs by mixing their values with some random noise. The formula used is, up to some normalizing constant: new_cpt = (1-noise) * cpt + noise * random_cpt(). Of course, noise must belong to interval [0,1].
Returns
the BNLearner (so that we can chains the calls to useXXX() methods)
Exceptions
OutOfBoundsis raised if epsilon is not strictly positive or if noise does not belong to interval [0,1].

References BNLearner(), gum::learning::IBNLearner::epsilon(), and useEMWithRateCriterion().

Referenced by useEMWithRateCriterion(), and useEMWithRateCriterion().

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

◆ useExtendedGreedyHillClimbing()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useExtendedGreedyHillClimbing ( )

References BNLearner(), and useExtendedGreedyHillClimbing().

Referenced by useExtendedGreedyHillClimbing().

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

◆ useFCI()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useFCI ( )

References BNLearner(), and useFCI().

Referenced by useFCI().

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

◆ useFCIChi2Test()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useFCIChi2Test ( )

References BNLearner(), and useFCIChi2Test().

Referenced by useFCIChi2Test().

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

◆ useFCIG2Test()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useFCIG2Test ( )

References BNLearner(), and useFCIG2Test().

Referenced by useFCIG2Test().

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

◆ useG2Test()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useG2Test ( )

References BNLearner(), and useG2Test().

Referenced by useG2Test().

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

◆ useGreedyHillClimbing()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useGreedyHillClimbing ( )

References BNLearner(), and useGreedyHillClimbing().

Referenced by useGreedyHillClimbing().

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

◆ useGreedyThickThinning()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useGreedyThickThinning ( )

References BNLearner(), and useGreedyThickThinning().

Referenced by useGreedyThickThinning().

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

◆ useK2() [1/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useK2 ( const Sequence< NodeId > & order)

References BNLearner(), and useK2().

Referenced by useK2(), and useK2().

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

◆ useK2() [2/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useK2 ( const std::vector< NodeId > & order)

References BNLearner(), and useK2().

Here is the call graph for this function:

◆ useLocalSearchWithTabuList() [1/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useLocalSearchWithTabuList ( )

use a local search with tabu list and the default parameters (keys tabuListSize and tabuNbDecrease)

References BNLearner(), and useLocalSearchWithTabuList().

Here is the call graph for this function:

◆ useLocalSearchWithTabuList() [2/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useLocalSearchWithTabuList ( Size tabu_size)

use a local search with tabu list, with the default number of decreasing changes (key tabuNbDecrease of the section learning of gum::Configuration)

References BNLearner(), and useLocalSearchWithTabuList().

Here is the call graph for this function:

◆ useLocalSearchWithTabuList() [3/3]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useLocalSearchWithTabuList ( Size tabu_size,
Size nb_decrease )

References BNLearner(), and useLocalSearchWithTabuList().

Referenced by useLocalSearchWithTabuList(), useLocalSearchWithTabuList(), and useLocalSearchWithTabuList().

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

◆ useMDLCorrection()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useMDLCorrection ( )

References BNLearner(), and useMDLCorrection().

Referenced by useMDLCorrection().

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

◆ useMIIC()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useMIIC ( )

References BNLearner(), and useMIIC().

Referenced by useMIIC().

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

◆ useNMLCorrection()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useNMLCorrection ( )

References BNLearner(), and useNMLCorrection().

Referenced by useNMLCorrection().

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

◆ useNoCorrection()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useNoCorrection ( )

References BNLearner(), and useNoCorrection().

Referenced by useNoCorrection().

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

◆ useNoPrior()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useNoPrior ( )

References BNLearner(), and useNoPrior().

Referenced by useNoPrior().

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

◆ usePC()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::usePC ( )

References BNLearner(), and usePC().

Referenced by usePC().

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

◆ useScoreAIC()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useScoreAIC ( )

References BNLearner(), and useScoreAIC().

Referenced by useScoreAIC().

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

◆ useScoreBD()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useScoreBD ( )

References BNLearner(), and useScoreBD().

Referenced by useScoreBD().

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

◆ useScoreBDeu()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useScoreBDeu ( )

References BNLearner(), and useScoreBDeu().

Referenced by useScoreBDeu().

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

◆ useScoreBIC()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useScoreBIC ( )

References BNLearner(), and useScoreBIC().

Referenced by useScoreBIC().

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

◆ useScorefNML()

INLINE void gum::learning::IBNLearner::useScorefNML ( )
inherited

indicate that we wish to use a fNML score

Definition at line 194 of file IBNLearner_inl.h.

References checkScorePriorCompatibility(), fNML, and scoreType_.

Here is the call graph for this function:

◆ useScoreK2()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useScoreK2 ( )

References BNLearner(), and useScoreK2().

Referenced by useScoreK2().

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

◆ useScoreLog2Likelihood()

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useScoreLog2Likelihood ( )

References BNLearner(), and useScoreLog2Likelihood().

Referenced by useScoreLog2Likelihood().

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

◆ useScoreMDL()

INLINE void gum::learning::IBNLearner::useScoreMDL ( )
inherited

indicate that we wish to use a MDL score

Definition at line 212 of file IBNLearner_inl.h.

References checkScorePriorCompatibility(), MDL, and scoreType_.

Here is the call graph for this function:

◆ useSmoothingPrior() [1/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useSmoothingPrior ( )

use the smoothing prior with the default weight (key priorWeight)

References BNLearner(), and useSmoothingPrior().

Here is the call graph for this function:

◆ useSmoothingPrior() [2/2]

template<GUM_Numeric GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useSmoothingPrior ( double weight)

References BNLearner(), and useSmoothingPrior().

Referenced by useSmoothingPrior(), and useSmoothingPrior().

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

◆ verbosity()

INLINE bool gum::learning::IBNLearner::verbosity ( ) const
overridevirtualinherited

verbosity

Implements gum::IApproximationSchemeConfiguration.

Definition at line 979 of file IBNLearner_inl.h.

979 {
980 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->verbosity();
981 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
982 }

References currentAlgorithm_, GUM_ERROR, and gum::ApproximationScheme::verbosity().

Referenced by createPrior_().

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

Member Data Documentation

◆ _nb_threads_

Size gum::ThreadNumberManager::_nb_threads_ {0}
privateinherited

the max number of threads used by the class

Definition at line 126 of file threadNumberManager.h.

◆ _prior_bn_

template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR > gum::learning::BNLearner< GUM_SCALAR >::_prior_bn_
private

Definition at line 569 of file BNLearner.h.

◆ algoFCI_

gum::learning::FCI gum::learning::IBNLearner::algoFCI_
protectedinherited

the FCI algorithm

Definition at line 1263 of file IBNLearner.h.

Referenced by learnDag_(), learnPAG_(), learnPDAG_(), and prepareFCI_().

◆ algoK2_

◆ algoMiic_

Miic gum::learning::IBNLearner::algoMiic_
protectedinherited

the Constraint MIIC algorithm

Definition at line 1239 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), latentVariables(), learnDag_(), learnPDAG_(), operator=(), operator=(), and prepareMiic_().

◆ algoPC_

gum::learning::PC gum::learning::IBNLearner::algoPC_
protectedinherited

the PC algorithm

Definition at line 1246 of file IBNLearner.h.

Referenced by learnDag_(), learnPDAG_(), and preparePC_().

◆ allowArcAdditions_

bool gum::learning::IBNLearner::allowArcAdditions_ {true}
protectedinherited

whether we allow or not arc additions during learning

Definition at line 1224 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), allowArcAdditions(), learnDag_(), operator=(), and operator=().

◆ allowArcDeletions_

bool gum::learning::IBNLearner::allowArcDeletions_ {true}
protectedinherited

whether we allow or not arc deletions during learning

Definition at line 1227 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), allowArcDeletions(), learnDag_(), operator=(), and operator=().

◆ allowArcReversals_

bool gum::learning::IBNLearner::allowArcReversals_ {true}
protectedinherited

whether we allow or not arc reversals during learning

Definition at line 1230 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), allowArcReversals(), learnDag_(), operator=(), and operator=().

◆ allowArcTriangleDeletions_

bool gum::learning::IBNLearner::allowArcTriangleDeletions_ {true}
protectedinherited

whether we allow or not arc deletions during learning

Definition at line 1233 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), allowArcTriangleDeletions(), learnDag_(), operator=(), and operator=().

◆ alphaFci_

double gum::learning::IBNLearner::alphaFci_ {gum::config().typed< double >("learning", "alpha")}
protectedinherited

FCI parameters the threshold of the tests ; it is initialized from the key learning.alpha.

Definition at line 1273 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), operator=(), operator=(), prepareFCI_(), and setFCIAlpha().

◆ alphaPc_

double gum::learning::IBNLearner::alphaPc_ {gum::config().typed< double >("learning", "alpha")}
protectedinherited

PC parameters the threshold of the tests ; it is initialized from the key learning.alpha.

Definition at line 1257 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), operator=(), operator=(), preparePC_(), and setPCAlpha().

◆ constraintForbiddenArcs_

StructuralConstraintForbiddenArcs gum::learning::IBNLearner::constraintForbiddenArcs_
protectedinherited

◆ constraintIndegree_

StructuralConstraintIndegree gum::learning::IBNLearner::constraintIndegree_
protectedinherited

the constraint for indegrees

Definition at line 1200 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), learnDag_(), operator=(), operator=(), prepareFCI_(), prepareMiic_(), preparePC_(), and setMaxIndegree().

◆ constraintMandatoryArcs_

StructuralConstraintMandatoryArcs gum::learning::IBNLearner::constraintMandatoryArcs_
protectedinherited

◆ constraintNoChildrenNodes_

StructuralConstraintNoChildrenNodes gum::learning::IBNLearner::constraintNoChildrenNodes_
protectedinherited

the constraint on no children nodes

Definition at line 1218 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), addNoChildrenNode(), eraseNoChildrenNode(), learnDag_(), operator=(), operator=(), prepareFCI_(), prepareMiic_(), and preparePC_().

◆ constraintNoParentNodes_

StructuralConstraintNoParentNodes gum::learning::IBNLearner::constraintNoParentNodes_
protectedinherited

the constraint on no parent nodes

Definition at line 1215 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), addNoParentNode(), eraseNoParentNode(), learnDag_(), operator=(), operator=(), prepareFCI_(), prepareMiic_(), and preparePC_().

◆ constraintPossibleEdges_

StructuralConstraintPossibleEdges gum::learning::IBNLearner::constraintPossibleEdges_
protectedinherited

the constraint on possible Edges

Definition at line 1209 of file IBNLearner.h.

Referenced by addPossibleEdge(), erasePossibleEdge(), learnDag_(), prepareFCI_(), prepareMiic_(), preparePC_(), and setPossibleEdges().

◆ constraintSliceOrder_

StructuralConstraintSliceOrder gum::learning::IBNLearner::constraintSliceOrder_
protectedinherited

the constraint for 2TBNs

Definition at line 1194 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), learnDag_(), operator=(), operator=(), prepareFCI_(), prepareMiic_(), preparePC_(), and setSliceOrder().

◆ constraintTabuList_

StructuralConstraintTabuList gum::learning::IBNLearner::constraintTabuList_
protectedinherited

the constraint for tabu lists

Definition at line 1203 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), learnDag_(), operator=(), operator=(), and useLocalSearchWithTabuList().

◆ constraintTotalOrder_

StructuralConstraintTotalOrder gum::learning::IBNLearner::constraintTotalOrder_
protectedinherited

the total order ing constraint

Definition at line 1197 of file IBNLearner.h.

Referenced by learnDag_(), prepareFCI_(), prepareMiic_(), preparePC_(), and setTotalOrder().

◆ currentAlgorithm_

◆ dag2BN_

◆ exhaustiveSepSetFci_

bool gum::learning::IBNLearner::exhaustiveSepSetFci_ {false}
protectedinherited

◆ extendedGreedyHillClimbing_

GreedyHillClimbing gum::learning::IBNLearner::extendedGreedyHillClimbing_
protectedinherited

the extended greedy hill climbing

Definition at line 1284 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), learnDag_(), operator=(), and operator=().

◆ filename_

std::string gum::learning::IBNLearner::filename_ {"-"}
protectedinherited

the filename database

Definition at line 1308 of file IBNLearner.h.

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

◆ greedyHillClimbing_

◆ greedyThickThinning_

GreedyThickThinning gum::learning::IBNLearner::greedyThickThinning_
protectedinherited

the greedy thick-thinning algorithm

Definition at line 1287 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), greedyThickThinningReversals(), learnDag_(), operator=(), operator=(), and setGreedyThickThinningReversals().

◆ indepTestFCI_

IndependenceTest* gum::learning::IBNLearner::indepTestFCI_ {nullptr}
protectedinherited

owned independence test object for FCI (rebuilt before each learn call)

Definition at line 1269 of file IBNLearner.h.

Referenced by ~IBNLearner(), and prepareFCI_().

◆ indepTestPC_

IndependenceTest* gum::learning::IBNLearner::indepTestPC_ {nullptr}
protectedinherited

owned independence test object for PC (rebuilt before each learn call)

Definition at line 1253 of file IBNLearner.h.

Referenced by ~IBNLearner(), and preparePC_().

◆ indepTestTypeFCI_

IndepTestType gum::learning::IBNLearner::indepTestTypeFCI_ {IndepTestType::Chi2}
protectedinherited

independence test type for FCI (reuses IndepTestType defined above)

Definition at line 1266 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), operator=(), operator=(), prepareFCI_(), useFCIChi2Test(), and useFCIG2Test().

◆ indepTestTypePC_

IndepTestType gum::learning::IBNLearner::indepTestTypePC_ {IndepTestType::Chi2}
protectedinherited

◆ inducedTypes_

bool gum::learning::IBNLearner::inducedTypes_ {false}
protectedinherited

the policy for typing variables

Definition at line 1164 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), IBNLearner(), and IBNLearner().

◆ initialDag_

DAG gum::learning::IBNLearner::initialDag_
protectedinherited

an initial DAG given to learners

Definition at line 1305 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), initialDAG(), learnDag_(), operator=(), operator=(), and setInitialDAG().

◆ kmodeMiic_

◆ localSearchWithTabuList_

◆ maxCondSetSizePc_

Size gum::learning::IBNLearner::maxCondSetSizePc_ {Size(-1)}
protectedinherited

◆ maxPathLengthFci_

Size gum::learning::IBNLearner::maxPathLengthFci_ {Size(-1)}
protectedinherited

◆ mutualInfo_

CorrectedMutualInformation* gum::learning::IBNLearner::mutualInfo_ {nullptr}
protectedinherited

the selected correction for miic

Definition at line 1179 of file IBNLearner.h.

Referenced by ~IBNLearner(), createCorrectedMutualInformation_(), learnDag_(), learnPDAG_(), operator=(), and operator=().

◆ nbDecreasingChanges_

Size gum::learning::IBNLearner::nbDecreasingChanges_ {2}
protectedinherited

◆ noPrior_

NoPrior* gum::learning::IBNLearner::noPrior_ {nullptr}
protectedinherited

◆ onProgress

◆ onStop

Signaler< std::string_view > gum::IApproximationSchemeConfiguration::onStop
inherited

Criteria messageApproximationScheme.

Definition at line 84 of file IApproximationSchemeConfiguration.h.

Referenced by gum::learning::IBNLearner::distributeStop().

◆ paramEstimatorType_

ParamEstimatorType gum::learning::IBNLearner::paramEstimatorType_ {ParamEstimatorType::ML}
protectedinherited

the type of the parameter estimator

Definition at line 1173 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), createParamEstimator_(), operator=(), and operator=().

◆ prior_

Prior* gum::learning::IBNLearner::prior_ {nullptr}
protectedinherited

◆ priorDatabase_

Database* gum::learning::IBNLearner::priorDatabase_ {nullptr}
protectedinherited

the database used by the Dirichlet a priori

Definition at line 1299 of file IBNLearner.h.

Referenced by ~IBNLearner(), learnDag_(), operator=(), and operator=().

◆ priorDbname_

std::string gum::learning::IBNLearner::priorDbname_
protectedinherited

the filename for the Dirichlet a priori, if any

Definition at line 1302 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), operator=(), operator=(), and useDirichletPrior().

◆ priorType_

BNLearnerPriorType gum::learning::IBNLearner::priorType_ {BNLearnerPriorType::NO_prior}
protectedinherited

the a priorselected for the score and parameters

Definition at line 1182 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), getPriorType_(), learnDag_(), operator=(), operator=(), useBDeuPrior(), useDirichletPrior(), useNoPrior(), and useSmoothingPrior().

◆ priorWeight_

double gum::learning::IBNLearner::priorWeight_ {1.0f}
protectedinherited

the weight of the prior. It is always written by the useXxxPrior() methods, which read learning.priorWeight when no weight is given.

Definition at line 1191 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), _setPriorWeight_(), checkScorePriorCompatibility(), operator=(), and operator=().

◆ ranges_

std::vector< std::pair< std::size_t, std::size_t > > gum::learning::IBNLearner::ranges_
protectedinherited

◆ score_

Score* gum::learning::IBNLearner::score_ {nullptr}
protectedinherited

◆ scoreDatabase_

◆ scoreType_

ScoreType gum::learning::IBNLearner::scoreType_ {ScoreType::BDeu}
protectedinherited

◆ selectedAlgo_

◆ sortedUCPc_

bool gum::learning::IBNLearner::sortedUCPc_ {false}
protectedinherited

◆ stablePc_

bool gum::learning::IBNLearner::stablePc_ {true}
protectedinherited

Definition at line 1258 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), operator=(), operator=(), preparePC_(), and setPCStable().

◆ tabuListSize_

Size gum::learning::IBNLearner::tabuListSize_ {100}
protectedinherited

◆ useEM_

bool gum::learning::IBNLearner::useEM_ {false}
protectedinherited

a Boolean indicating whether we should use EM for parameter learning or not

Definition at line 1176 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), EM(), EMState(), EMStateMessage(), forbidEM(), isUsingEM(), operator=(), operator=(), useEM(), and useEMWithDiffCriterion().


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