aGrUM 2.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 >:
Collaboration diagram for gum::learning::BNLearner< GUM_SCALAR >:

Public Types

enum class  ScoreType {
  AIC , BD , BDeu , BIC ,
  K2 , LOG2LIKELIHOOD
}
 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 }
 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=default_EM_noise)
 use The EM algorithm to learn parameters
BNLearner< GUM_SCALAR > & useEMWithRateCriterion (const double epsilon, const double noise=default_EM_noise)
 use The EM algorithm to learn parameters with the rate stopping criterion
BNLearner< GUM_SCALAR > & useEMWithDiffCriterion (const double epsilon, const double noise=default_EM_noise)
 use The EM algorithm to learn parameters with the diff stopping criterion
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=1.0)
BNLearner< GUM_SCALAR > & useSmoothingPrior (double weight=1)
BNLearner< GUM_SCALAR > & useDirichletPrior (const std::string &filename, double weight=1)
BNLearner< GUM_SCALAR > & useDirichletPrior (const gum::BayesNet< GUM_SCALAR > &bn, double weight=1)
BNLearner< GUM_SCALAR > & useGreedyHillClimbing ()
BNLearner< GUM_SCALAR > & useLocalSearchWithTabuList (Size tabu_size=100, Size nb_decrease=2)
BNLearner< GUM_SCALAR > & useK2 (const Sequence< NodeId > &order)
BNLearner< GUM_SCALAR > & useK2 (const std::vector< NodeId > &order)
BNLearner< GUM_SCALAR > & useMIIC ()
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 > & setForbiddenArcs (const ArcSet &set)
BNLearner< GUM_SCALAR > & addForbiddenArc (const Arc &arc)
BNLearner< GUM_SCALAR > & addForbiddenArc (NodeId tail, NodeId head)
BNLearner< GUM_SCALAR > & addForbiddenArc (const std::string &tail, const std::string &head)
BNLearner< GUM_SCALAR > & eraseForbiddenArc (const Arc &arc)
BNLearner< GUM_SCALAR > & eraseForbiddenArc (NodeId tail, NodeId head)
BNLearner< GUM_SCALAR > & eraseForbiddenArc (const std::string &tail, const std::string &head)
BNLearner< GUM_SCALAR > & addMandatoryArc (const Arc &arc)
BNLearner< GUM_SCALAR > & addMandatoryArc (NodeId tail, NodeId head)
BNLearner< GUM_SCALAR > & addMandatoryArc (const std::string &tail, const std::string &head)
BNLearner< GUM_SCALAR > & eraseMandatoryArc (const Arc &arc)
BNLearner< GUM_SCALAR > & eraseMandatoryArc (NodeId tail, NodeId head)
BNLearner< GUM_SCALAR > & eraseMandatoryArc (const std::string &tail, const std::string &head)
BNLearner< GUM_SCALAR > & addPossibleEdge (const Edge &edge)
BNLearner< GUM_SCALAR > & addPossibleEdge (NodeId tail, NodeId head)
BNLearner< GUM_SCALAR > & addPossibleEdge (const std::string &tail, const std::string &head)
BNLearner< GUM_SCALAR > & erasePossibleEdge (const Edge &edge)
BNLearner< GUM_SCALAR > & erasePossibleEdge (NodeId tail, NodeId head)
BNLearner< GUM_SCALAR > & erasePossibleEdge (const std::string &tail, const std::string &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 (const std::string &name)
BNLearner< GUM_SCALAR > & eraseNoParentNode (NodeId node)
BNLearner< GUM_SCALAR > & eraseNoParentNode (const std::string &name)
BNLearner< GUM_SCALAR > & addNoChildrenNode (NodeId node)
BNLearner< GUM_SCALAR > & addNoChildrenNode (const std::string &name)
BNLearner< GUM_SCALAR > & eraseNoChildrenNode (NodeId node)
BNLearner< GUM_SCALAR > & eraseNoChildrenNode (const std::string &name)
bool isConstraintBased () const
bool isScoreBased () const
Size EMPeriodSize () const
Constructors / Destructors
 BNLearner (const std::string &filename, const std::vector< std::string > &missingSymbols={"?"}, const bool induceTypes=true)
 default constructor
 BNLearner (const DatabaseTable &db)
 default constructor
 BNLearner (const std::string &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
virtual ~BNLearner ()
 destructor
Operators
BNLearneroperator= (const BNLearner &)
 copy operator
BNLearneroperator= (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)
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 (const std::string &var) const
 learn a structure from a file (must have read the db before)
NodeId idFromName (const std::string &var_name) const
 returns the node id corresponding to a variable name
const DatabaseTabledatabase () 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, doublechi2 (NodeId id1, NodeId id2, const std::vector< NodeId > &knowing={})
 Return the <statistic,pvalue> pair for chi2 test in the database.
std::pair< double, doublechi2 (const std::string &name1, const std::string &name2, const std::vector< std::string > &knowing={})
 Return the <statistic,pvalue> pair for the BNLearner.
std::pair< double, doubleG2 (NodeId id1, NodeId id2, const std::vector< NodeId > &knowing={})
 Return the <statistic,pvalue> pair for for G2 test in the database.
std::pair< double, doubleG2 (const std::string &name1, const std::string &name2, const std::vector< std::string > &knowing={})
 Return the <statistic,pvalue> pair for for G2 test in the database.
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 (const std::string &var1, const std::string &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 (const std::string &var1, const std::string &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 (const std::string &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< doublerawPseudoCount (const std::vector< NodeId > &vars)
 Return the pseudo-counts of NodeIds vars in the base in a raw array.
std::vector< doublerawPseudoCount (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
EMApproximationSchemeEM ()
 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
a prior selection / parameterization
std::string checkScorePriorCompatibility () const
 checks whether the current score and prior are compatible
MIIC parameterization and specific results
std::vector< ArclatentVariables () const
 get the list of arcs hiding latent variables
Multithreading
void setNumberOfThreads (Size nb) override
 sets the number max of threads that can be used
redistribute signals AND implementation of interface
INLINE void setCurrentApproximationScheme (const ApproximationScheme *approximationScheme)
 {@ /// distribute signals
INLINE void distributeProgress (const ApproximationScheme *approximationScheme, Size pourcent, double error, double time)
 {@ /// distribute signals
INLINE void distributeStop (const ApproximationScheme *approximationScheme, const std::string &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
virtual Size getNumberOfThreads () const
 returns the current max number of threads used by the class containing this ThreadNumberManager
bool isGumNumberOfThreadsOverriden () const
 indicates whether the class containing this ThreadNumberManager set its own number of threads

Public Attributes

Signaler3< Size, double, doubleonProgress
 Progression, error and time.
Signaler1< const std::string & > onStop
 Criteria messageApproximationScheme.

Static Public Attributes

static constexpr double default_EM_noise {0.1}
 the default noise amount added to CPTs during EM's initialization (see method useEM())

Protected Member Functions

void createPrior_ ()
 create the prior used for learning
void _setPriorWeight_ (double weight)
 sets the prior weight
void createScore_ ()
 create the score used for learning
ParamEstimatorcreateParamEstimator_ (const DBRowGeneratorParser &parser, bool take_into_account_score=true)
 create the parameter estimator used for learning
DAG learnDag_ ()
 returns the DAG learnt
MixedGraph prepareSimpleMiic_ ()
 prepares the initial graph for Simple Miic
MixedGraph prepareMiic_ ()
 prepares the initial graph for miic
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_ (const std::string &filename, const std::vector< std::string > &missing_symbols)
 reads a file and returns a databaseVectInRam
static void isCSVFileName_ (const std::string &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
Scorescore_ {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
double noiseEM_ {0.1}
 the noise factor (in (0,1)) used by EM for perturbing the CPT during init
CorrectedMutualInformationmutualInfo_ {nullptr}
 the selected correction for miic
BNLearnerPriorType priorType_ {BNLearnerPriorType::NO_prior}
 the a priorselected for the score and parameters
Priorprior_ {nullptr}
 the prior used
NoPriornoPrior_ {nullptr}
double priorWeight_ {1.0f}
 the weight of the prior
StructuralConstraintSliceOrder constraintSliceOrder_
 the constraint for 2TBNs
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_ {AlgoType::MIIC}
 the selected learning algorithm
K2 algoK2_
 the K2 algorithm
SimpleMiic algoSimpleMiic_
 the MIIC algorithm
Miic algoMiic_
 the Constraint MIIC algorithm
CorrectedMutualInformation::KModeTypes kmodeMiic_
 the penalty used in MIIC
DAG2BNLearner dag2BN_
 the parametric EM
GreedyHillClimbing greedyHillClimbing_
 the greedy hill climbing 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
DatabasepriorDatabase_ {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 nbDecreasingChanges_ {2}
const ApproximationSchemecurrentAlgorithm_ {nullptr}

Private Member Functions

NodeProperty< Sequence< std::string > > _labelsFromBN_ (const std::string &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<typename 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 74 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 

Definition at line 117 of file IBNLearner.h.

117{ K2, GREEDY_HILL_CLIMBING, LOCAL_SEARCH_WITH_TABU_LIST, MIIC };

◆ ApproximationSchemeSTATE

The different state of an approximation scheme.

Enumerator
Undefined 
Continue 
Epsilon 
Rate 
Limit 
TimeLimit 
Stopped 

Definition at line 86 of file IApproximationSchemeConfiguration.h.

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

◆ BNLearnerPriorType

an enumeration to select the prior

Enumerator
NO_prior 
SMOOTHING 
DIRICHLET_FROM_DATABASE 
DIRICHLET_FROM_BAYESNET 
BDEU 

Definition at line 108 of file IBNLearner.h.

108 {
109 NO_prior,
110 SMOOTHING,
111 DIRICHLET_FROM_DATABASE,
112 DIRICHLET_FROM_BAYESNET,
113 BDEU
114 };

◆ ParamEstimatorType

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

Enumerator
ML 

Definition at line 105 of file IBNLearner.h.

105{ 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 
K2 
LOG2LIKELIHOOD 

Definition at line 101 of file IBNLearner.h.

101{ AIC, BD, BDeu, BIC, K2, LOG2LIKELIHOOD };

Constructor & Destructor Documentation

◆ BNLearner() [1/5]

template<typename GUM_SCALAR>
gum::learning::BNLearner< GUM_SCALAR >::BNLearner ( const std::string & 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(), 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=(), setForbiddenArcs(), setInitialDAG(), setMandatoryArcs(), setMaxIndegree(), setPossibleEdges(), setPossibleSkeleton(), setSliceOrder(), useBDeuPrior(), useDirichletPrior(), useDirichletPrior(), useEM(), useEMWithDiffCriterion(), useEMWithRateCriterion(), useGreedyHillClimbing(), useK2(), useK2(), useLocalSearchWithTabuList(), useMDLCorrection(), useMIIC(), useNMLCorrection(), useNoCorrection(), useNoPrior(), useScoreAIC(), useScoreBD(), useScoreBDeu(), useScoreBIC(), useScoreK2(), useScoreLog2Likelihood(), and useSmoothingPrior().

◆ BNLearner() [2/5]

template<typename 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<typename GUM_SCALAR>
gum::learning::BNLearner< GUM_SCALAR >::BNLearner ( const std::string & 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<typename 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<typename 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<typename GUM_SCALAR>
virtual gum::learning::BNLearner< GUM_SCALAR >::~BNLearner ( )
virtual

destructor

Member Function Documentation

◆ _checkDAGCompatibility_()

template<typename 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

◆ _initializeEMParameterLearning_()

template<typename 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.

◆ _labelsFromBN_()

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

read the first line of a file to find column names

◆ _learnParameters_()

template<typename 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

◆ _learnParametersWithEM_() [1/2]

template<typename 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.

◆ _learnParametersWithEM_() [2/2]

template<typename 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.

◆ _setPriorWeight_()

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

sets the prior weight

Definition at line 473 of file IBNLearner_inl.h.

473 {
474 if (weight < 0) { GUM_ERROR(OutOfBounds, "the weight of the prior must be positive") }
475
476 priorWeight_ = weight;
478 }
double priorWeight_
the weight of the prior
Definition IBNLearner.h:964
std::string checkScorePriorCompatibility() const
checks whether the current score and prior are compatible
#define GUM_ERROR(type, msg)
Definition exceptions.h:72

References checkScorePriorCompatibility(), GUM_ERROR, and priorWeight_.

Referenced by useBDeuPrior(), gum::learning::BNLearner< GUM_SCALAR >::useDirichletPrior(), useDirichletPrior(), and useSmoothingPrior().

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

◆ addForbiddenArc() [1/3]

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

Definition at line 559 of file BNLearner.h.

559 {
561 return *this;
562 }
A pack of learning algorithms that can easily be used.
Definition BNLearner.h:74
void addForbiddenArc(const Arc &arc)

References BNLearner(), and gum::learning::IBNLearner::addForbiddenArc().

Here is the call graph for this function:

◆ addForbiddenArc() [2/3]

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addForbiddenArc ( const std::string & tail,
const std::string & head )
inline

Definition at line 569 of file BNLearner.h.

569 {
571 return *this;
572 }

References BNLearner(), and gum::learning::IBNLearner::addForbiddenArc().

Here is the call graph for this function:

◆ addForbiddenArc() [3/3]

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

Definition at line 564 of file BNLearner.h.

564 {
566 return *this;
567 }

References BNLearner(), and gum::learning::IBNLearner::addForbiddenArc().

Here is the call graph for this function:

◆ addMandatoryArc() [1/3]

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

Definition at line 589 of file BNLearner.h.

589 {
591 return *this;
592 }
void addMandatoryArc(const Arc &arc)

References BNLearner(), and gum::learning::IBNLearner::addMandatoryArc().

Here is the call graph for this function:

◆ addMandatoryArc() [2/3]

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addMandatoryArc ( const std::string & tail,
const std::string & head )
inline

Definition at line 599 of file BNLearner.h.

599 {
601 return *this;
602 }

References BNLearner(), and gum::learning::IBNLearner::addMandatoryArc().

Here is the call graph for this function:

◆ addMandatoryArc() [3/3]

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

Definition at line 594 of file BNLearner.h.

594 {
596 return *this;
597 }

References BNLearner(), and gum::learning::IBNLearner::addMandatoryArc().

Here is the call graph for this function:

◆ addNoChildrenNode() [1/2]

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addNoChildrenNode ( const std::string & name)
inline

Definition at line 689 of file BNLearner.h.

689 {
691 return *this;
692 }
void addNoChildrenNode(NodeId node)

References BNLearner(), and gum::learning::IBNLearner::addNoChildrenNode().

Here is the call graph for this function:

◆ addNoChildrenNode() [2/2]

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

Definition at line 684 of file BNLearner.h.

684 {
686 return *this;
687 }

References BNLearner(), and gum::learning::IBNLearner::addNoChildrenNode().

Here is the call graph for this function:

◆ addNoParentNode() [1/2]

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addNoParentNode ( const std::string & name)
inline

Definition at line 669 of file BNLearner.h.

669 {
671 return *this;
672 }
void addNoParentNode(NodeId node)

References BNLearner(), and gum::learning::IBNLearner::addNoParentNode().

Here is the call graph for this function:

◆ addNoParentNode() [2/2]

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

Definition at line 664 of file BNLearner.h.

664 {
666 return *this;
667 }

References BNLearner(), and gum::learning::IBNLearner::addNoParentNode().

Here is the call graph for this function:

◆ addPossibleEdge() [1/3]

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

Definition at line 619 of file BNLearner.h.

619 {
621 return *this;
622 }
void addPossibleEdge(const Edge &edge)

References BNLearner(), and gum::learning::IBNLearner::addPossibleEdge().

Here is the call graph for this function:

◆ addPossibleEdge() [2/3]

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::addPossibleEdge ( const std::string & tail,
const std::string & head )
inline

Definition at line 629 of file BNLearner.h.

629 {
631 return *this;
632 }

References BNLearner(), and gum::learning::IBNLearner::addPossibleEdge().

Here is the call graph for this function:

◆ addPossibleEdge() [3/3]

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

Definition at line 624 of file BNLearner.h.

624 {
626 return *this;
627 }

References BNLearner(), and gum::learning::IBNLearner::addPossibleEdge().

Here is the call 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 899 of file IBNLearner.cpp.

899 {
900 if (this->isConstraintBased()) return "";
901
902 const auto prior = getPriorType_();
903
904 switch (scoreType_) {
906 case AIC : return ScoreAIC::isPriorCompatible(prior, priorWeight_);
907
908 case BD : return ScoreBD::isPriorCompatible(prior, priorWeight_);
909
910 case BDeu : return ScoreBDeu::isPriorCompatible(prior, priorWeight_);
911
912 case BIC : return ScoreBIC::isPriorCompatible(prior, priorWeight_);
913
914 case K2 : return ScoreK2::isPriorCompatible(prior, priorWeight_);
915
917
918 default : return "IBNLearner does not support yet this score";
919 }
920 }
ScoreType
an enumeration enabling to select easily the score we wish to use
Definition IBNLearner.h:101
bool isConstraintBased() const
indicate if the selected algorithm is constraint-based
Definition IBNLearner.h:777
ScoreType scoreType_
the score selected for learning
Definition IBNLearner.h:938
PriorType getPriorType_() const
returns the type (as a string) of a given prior
virtual std::string isPriorCompatible() const final
indicates whether the prior is compatible (meaningful) with the score
virtual 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
virtual std::string isPriorCompatible() const final
indicates whether the prior is compatible (meaningful) with the score
virtual std::string isPriorCompatible() const final
indicates whether the prior is compatible (meaningful) with the score
virtual std::string isPriorCompatible() const final
indicates whether the prior is compatible (meaningful) with the score

References AIC, BD, BDeu, BIC, getPriorType_(), isConstraintBased(), gum::learning::ScoreAIC::isPriorCompatible(), gum::learning::ScoreBD::isPriorCompatible(), gum::learning::ScoreBDeu::isPriorCompatible(), gum::learning::ScoreBIC::isPriorCompatible(), gum::learning::ScoreK2::isPriorCompatible(), gum::learning::ScoreLog2Likelihood::isPriorCompatible(), LOG2LIKELIHOOD, priorWeight_, and scoreType_.

Referenced by _setPriorWeight_(), useBDeuPrior(), gum::learning::BNLearner< GUM_SCALAR >::useDirichletPrior(), useDirichletPrior(), useNoPrior(), useScoreAIC(), useScoreBD(), useScoreBDeu(), useScoreBIC(), useScoreK2(), useScoreLog2Likelihood(), 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 ( const std::string & name1,
const std::string & 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 970 of file IBNLearner.cpp.

972 {
973 std::vector< NodeId > knowingIds;
974 std::transform(knowing.begin(),
975 knowing.end(),
976 std::back_inserter(knowingIds),
977 [this](const std::string& c) { return this->idFromName(c); });
978 return chi2(idFromName(name1), idFromName(name2), knowingIds);
979 }
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(const std::string &var_name) const
returns the node id corresponding to a variable name

References chi2(), and idFromName().

Here is the call graph for this function:

◆ chi2() [2/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 963 of file IBNLearner.cpp.

963 {
964 createPrior_();
965 gum::learning::IndepTestChi2 chi2score(scoreDatabase_.parser(), *prior_, databaseRanges());
966
967 return chi2score.statistics(id1, id2, knowing);
968 }
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
Definition IBNLearner.h:959

References createPrior_(), databaseRanges(), 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:

◆ clearDatabaseRanges()

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

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

Definition at line 558 of file IBNLearner_inl.h.

558{ 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<typename 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 ( const std::string & var1,
const std::string & 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 1053 of file IBNLearner.cpp.

1055 {
1056 std::vector< NodeId > knowingIds;
1057
1058 auto mapper = [this](const std::string& c) { return this->idFromName(c); };
1059
1060 std::transform(knowing.begin(), knowing.end(), std::back_inserter(knowingIds), mapper);
1061
1062 return correctedMutualInformation(this->idFromName(var1), this->idFromName(var2), knowingIds);
1063 }
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:

◆ correctedMutualInformation() [2/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 1028 of file IBNLearner.cpp.

1030 {
1031 createPrior_();
1032 gum::learning::CorrectedMutualInformation cmi(scoreDatabase_.parser(),
1033 *prior_,
1034 databaseRanges());
1035
1036 switch (kmodeMiic_) {
1038 case MDL : cmi.useMDL(); break;
1039
1040 case NML : cmi.useNML(); break;
1041
1042 case NoCorr : cmi.useNoCorr(); break;
1043
1044 default :
1045 GUM_ERROR(NotImplementedYet,
1046 "The BNLearner's corrected mutual information class does "
1047 << "not implement yet this correction : " << int(kmodeMiic_))
1048 }
1049 if (knowing.size() == (Size)0) return cmi.score(id1, id2) / scoreDatabase_.weight();
1050 else return cmi.score(id1, id2, knowing) / scoreDatabase_.weight();
1051 }
KModeTypes
the description type for the complexity correction
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_, prior_, gum::learning::CorrectedMutualInformation::score(), scoreDatabase_, gum::learning::CorrectedMutualInformation::useMDL(), gum::learning::CorrectedMutualInformation::useNML(), and gum::learning::CorrectedMutualInformation::useNoCorr().

Referenced by correctedMutualInformation().

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

◆ createCorrectedMutualInformation_()

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

create the Corrected Mutual Information instance for Miic

Definition at line 710 of file IBNLearner.cpp.

710 {
711 if (mutualInfo_ != nullptr) delete mutualInfo_;
712
713 mutualInfo_ = new CorrectedMutualInformation(scoreDatabase_.parser(),
714 *noPrior_,
715 ranges_,
716 scoreDatabase_.nodeId2Columns());
717 switch (kmodeMiic_) {
719 case MDL : mutualInfo_->useMDL(); break;
720 case NML : mutualInfo_->useNML(); break;
721 case NoCorr : mutualInfo_->useNoCorr(); break;
722 default :
723 GUM_ERROR(NotImplementedYet,
724 "The BNLearner's corrected mutual information class does "
725 << "not implement yet this correction : " << int(kmodeMiic_))
726 }
727 }
CorrectedMutualInformation * mutualInfo_
the selected correction for miic
Definition IBNLearner.h:953

References GUM_ERROR, kmodeMiic_, mutualInfo_, noPrior_, ranges_, and scoreDatabase_.

Referenced by prepareMiic_().

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 527 of file IBNLearner.cpp.

528 {
529 ParamEstimator* param_estimator = nullptr;
530
531 // create the new estimator
532 switch (paramEstimatorType_) {
534 if (take_into_account_score && (score_ != nullptr)) {
535 param_estimator = new ParamEstimatorML(parser,
536 *prior_,
537 score_->internalPrior(),
538 ranges_,
539 scoreDatabase_.nodeId2Columns());
540 } else {
541 param_estimator = new ParamEstimatorML(parser,
542 *prior_,
543 *noPrior_,
544 ranges_,
545 scoreDatabase_.nodeId2Columns());
546 }
547
548 break;
549
550 default :
551 GUM_ERROR(OperationNotAllowed,
552 "IBNLearner does not support " << "yet this parameter estimator")
553 }
554
555 // assign the number of threads
556 param_estimator->setNumberOfThreads(
558
559 // assign the set of ranges
560 param_estimator->setRanges(ranges_);
561
562 return param_estimator;
563 }
bool isGumNumberOfThreadsOverriden() const
indicates whether the class containing this ThreadNumberManager set its own number of threads
virtual Size getNumberOfThreads() const
returns the current max number of threads used by the class containing this ThreadNumberManager
ParamEstimatorType paramEstimatorType_
the type of the parameter estimator
Definition IBNLearner.h:944
Score * score_
the score used
Definition IBNLearner.h:941

References gum::ThreadNumberManager::getNumberOfThreads(), GUM_ERROR, gum::ThreadNumberManager::isGumNumberOfThreadsOverriden(), ML, noPrior_, paramEstimatorType_, prior_, ranges_, score_, scoreDatabase_, gum::learning::ParamEstimator::setNumberOfThreads(), and gum::learning::ParamEstimator::setRanges().

Here is the call graph for this function:

◆ createPrior_()

template<typename GUM_SCALAR>
void gum::learning::BNLearner< GUM_SCALAR >::createPrior_ ( )
protectedvirtual

create the prior used for learning

Implements gum::learning::IBNLearner.

◆ createScore_()

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

create the score used for learning

Definition at line 468 of file IBNLearner.cpp.

468 {
469 // first, save the old score, to be delete if everything is ok
470 Score* old_score = score_;
471
472 // create the new scoring function
473 switch (scoreType_) {
474 case ScoreType::AIC :
475 score_ = new ScoreAIC(scoreDatabase_.parser(),
476 *prior_,
477 ranges_,
478 scoreDatabase_.nodeId2Columns());
479 break;
480
481 case ScoreType::BD :
482 score_ = new ScoreBD(scoreDatabase_.parser(),
483 *prior_,
484 ranges_,
485 scoreDatabase_.nodeId2Columns());
486 break;
487
488 case ScoreType::BDeu :
489 score_ = new ScoreBDeu(scoreDatabase_.parser(),
490 *prior_,
491 ranges_,
492 scoreDatabase_.nodeId2Columns());
493 break;
494
495 case ScoreType::BIC :
496 score_ = new ScoreBIC(scoreDatabase_.parser(),
497 *prior_,
498 ranges_,
499 scoreDatabase_.nodeId2Columns());
500 break;
501
502 case ScoreType::K2 :
503 score_ = new ScoreK2(scoreDatabase_.parser(),
504 *prior_,
505 ranges_,
506 scoreDatabase_.nodeId2Columns());
507 break;
508
510 score_ = new ScoreLog2Likelihood(scoreDatabase_.parser(),
511 *prior_,
512 ranges_,
513 scoreDatabase_.nodeId2Columns());
514 break;
515
516 default : GUM_ERROR(OperationNotAllowed, "IBNLearner does not support yet this score")
517 }
518
519 // remove the old score, if any
520 if (old_score != nullptr) delete old_score;
521
522 // assign the number of threads
523 score_->setNumberOfThreads(this->isGumNumberOfThreadsOverriden() ? this->getNumberOfThreads()
524 : 0);
525 }

References AIC, BD, BDeu, BIC, gum::ThreadNumberManager::getNumberOfThreads(), GUM_ERROR, gum::ThreadNumberManager::isGumNumberOfThreadsOverriden(), K2, LOG2LIKELIHOOD, prior_, ranges_, score_, scoreDatabase_, and scoreType_.

Referenced by learnDAG(), and score().

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

◆ currentTime()

double gum::learning::IBNLearner::currentTime ( ) const
inlineoverridevirtualinherited

get the current running time in second (double)

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1243 of file IBNLearner.h.

1243 {
1244 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->currentTime();
1245 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
1246 }
const ApproximationScheme * currentAlgorithm_

References currentAlgorithm_, and GUM_ERROR.

◆ database()

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

returns the database used by the BNLearner

Definition at line 561 of file IBNLearner_inl.h.

561 {
562 return scoreDatabase_.databaseTable();
563 }

References scoreDatabase_.

Referenced by readFile_().

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 553 of file IBNLearner_inl.h.

553 {
554 return ranges_;
555 }

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 160 of file IBNLearner_inl.h.

160{ return scoreDatabase_.weight(); }

References scoreDatabase_.

◆ disableEpsilon()

void gum::learning::IBNLearner::disableEpsilon ( )
inlineoverridevirtualinherited

Disable stopping criterion on epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1122 of file IBNLearner.h.

1122 {
1123 algoK2_.approximationScheme().disableEpsilon();
1124 greedyHillClimbing_.disableEpsilon();
1125 localSearchWithTabuList_.disableEpsilon();
1126 };
K2 algoK2_
the K2 algorithm
Definition IBNLearner.h:995
GreedyHillClimbing greedyHillClimbing_
the greedy hill climbing algorithm
LocalSearchWithTabuList localSearchWithTabuList_
the local search with tabu list algorithm

References algoK2_, greedyHillClimbing_, and localSearchWithTabuList_.

◆ disableMaxIter()

void gum::learning::IBNLearner::disableMaxIter ( )
inlineoverridevirtualinherited

Disable stopping criterion on max iterations.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1202 of file IBNLearner.h.

1202 {
1203 algoK2_.approximationScheme().disableMaxIter();
1204 greedyHillClimbing_.disableMaxIter();
1205 localSearchWithTabuList_.disableMaxIter();
1206 };

References algoK2_, greedyHillClimbing_, and localSearchWithTabuList_.

◆ disableMaxTime()

void gum::learning::IBNLearner::disableMaxTime ( )
inlineoverridevirtualinherited

Disable stopping criterion on timeout.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1249 of file IBNLearner.h.

1249 {
1250 algoK2_.approximationScheme().disableMaxTime();
1251 greedyHillClimbing_.disableMaxTime();
1252 localSearchWithTabuList_.disableMaxTime();
1253 };

References algoK2_, greedyHillClimbing_, and localSearchWithTabuList_.

◆ disableMinEpsilonRate()

void gum::learning::IBNLearner::disableMinEpsilonRate ( )
inlineoverridevirtualinherited

Disable stopping criterion on epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1162 of file IBNLearner.h.

1162 {
1163 algoK2_.approximationScheme().disableMinEpsilonRate();
1164 greedyHillClimbing_.disableMinEpsilonRate();
1165 localSearchWithTabuList_.disableMinEpsilonRate();
1166 };

References algoK2_, greedyHillClimbing_, and localSearchWithTabuList_.

◆ distributeProgress()

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

{@ /// distribute signals

Definition at line 1086 of file IBNLearner.h.

1089 {
1090 setCurrentApproximationScheme(approximationScheme);
1091
1092 if (onProgress.hasListener()) GUM_EMIT3(onProgress, pourcent, error, time);
1093 };
Signaler3< Size, double, double > onProgress
Progression, error and time.
INLINE void setCurrentApproximationScheme(const ApproximationScheme *approximationScheme)
{@ /// distribute signals
#define GUM_EMIT3(signal, arg1, arg2, arg3)
Definition signaler3.h:61

References GUM_EMIT3, gum::IApproximationSchemeConfiguration::onProgress, and setCurrentApproximationScheme().

Here is the call graph for this function:

◆ distributeStop()

INLINE void gum::learning::IBNLearner::distributeStop ( const ApproximationScheme * approximationScheme,
const std::string & message )
inlineinherited

distribute signals

Definition at line 1096 of file IBNLearner.h.

1097 {
1098 setCurrentApproximationScheme(approximationScheme);
1099
1100 if (onStop.hasListener()) GUM_EMIT1(onStop, message);
1101 };
Signaler1< const std::string & > onStop
Criteria messageApproximationScheme.
#define GUM_EMIT1(signal, arg1)
Definition signaler1.h:61

References GUM_EMIT1, gum::IApproximationSchemeConfiguration::onStop, and setCurrentApproximationScheme().

Here is the call graph for this function:

◆ domainSize() [1/2]

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

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

Definition at line 547 of file IBNLearner_inl.h.

547 {
548 return scoreDatabase_.domainSizes()[idFromName(var)];
549 }

References idFromName(), and scoreDatabase_.

Here is the call graph for this function:

◆ domainSize() [2/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 544 of file IBNLearner_inl.h.

544{ return scoreDatabase_.domainSizes()[var]; }

References scoreDatabase_.

◆ 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 539 of file IBNLearner_inl.h.

539 {
540 return scoreDatabase_.domainSizes();
541 }

References scoreDatabase_.

◆ 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 298 of file IBNLearner_inl.h.

298 {
299 if (useEM_) return dag2BN_;
300 else GUM_ERROR(NotFound, "EM is currently forbidden. Please enable it with useEM()")
301 }
bool useEM_
a Boolean indicating whether we should use EM for parameter learning or not
Definition IBNLearner.h:947
DAG2BNLearner dag2BN_
the parametric EM

References dag2BN_, GUM_ERROR, and useEM_.

◆ EMCurrentTime()

double gum::learning::IBNLearner::EMCurrentTime ( ) const
inlineinherited

get the current running time in second (double)

Definition at line 1422 of file IBNLearner.h.

1422{ return dag2BN_.currentTime(); }

References dag2BN_.

◆ EMdisableEpsilon()

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

Disable the min log-likelihood diff stopping criterion.

Definition at line 329 of file BNLearner.h.

329 {
331 return *this;
332 }
void EMdisableEpsilon()
Disable the min log-likelihood diff stopping criterion for EM.

References BNLearner(), and gum::learning::IBNLearner::EMdisableEpsilon().

Here is the call graph for this function:

◆ EMdisableMaxIter()

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

Disable stopping criterion on max iterations.

Definition at line 384 of file BNLearner.h.

384 {
386 return *this;
387 }
void EMdisableMaxIter()
Disable stopping criterion on max iterations.

References BNLearner(), and gum::learning::IBNLearner::EMdisableMaxIter().

Here is the call graph for this function:

◆ EMdisableMaxTime()

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

Disable EM's timeout stopping criterion.

Definition at line 406 of file BNLearner.h.

406 {
408 return *this;
409 }
void EMdisableMaxTime()
Disable EM's timeout stopping criterion.

References BNLearner(), and gum::learning::IBNLearner::EMdisableMaxTime().

Here is the call graph for this function:

◆ EMdisableMinEpsilonRate()

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

Disable the log-likelihood evolution rate stopping criterion.

Definition at line 358 of file BNLearner.h.

358 {
360 return *this;
361 }
void EMdisableMinEpsilonRate()
Disable the log-likelihood evolution rate stopping criterion.

References BNLearner(), and gum::learning::IBNLearner::EMdisableMinEpsilonRate().

Here is the call graph for this function:

◆ EMenableEpsilon()

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

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

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

Definition at line 339 of file BNLearner.h.

339 {
341 return *this;
342 }
void EMenableEpsilon()
Enable the log-likelihood min diff stopping criterion in EM.

References BNLearner(), and gum::learning::IBNLearner::EMenableEpsilon().

Here is the call graph for this function:

◆ EMenableMaxIter()

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

Enable stopping criterion on max iterations.

Definition at line 390 of file BNLearner.h.

390 {
392 return *this;
393 }
void EMenableMaxIter()
Enable stopping criterion on max iterations.

References BNLearner(), and gum::learning::IBNLearner::EMenableMaxIter().

Here is the call graph for this function:

◆ EMenableMaxTime()

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

enable EM's timeout stopping criterion

Definition at line 412 of file BNLearner.h.

412 {
414 return *this;
415 };
void EMenableMaxTime()
sets the stopping criterion of EM as being the minimal difference between two consecutive log-likelih...

References BNLearner(), and gum::learning::IBNLearner::EMenableMaxTime().

Here is the call graph for this function:

◆ EMenableMinEpsilonRate()

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

Enable the log-likelihood evolution rate stopping criterion.

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

Definition at line 368 of file BNLearner.h.

368 {
370 return *this;
371 }
void EMenableMinEpsilonRate()
Enable the log-likelihood evolution rate stopping criterion.

References BNLearner(), and gum::learning::IBNLearner::EMenableMinEpsilonRate().

Here is the call graph for this function:

◆ EMEpsilon()

double gum::learning::IBNLearner::EMEpsilon ( ) const
inlineinherited

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 1342 of file IBNLearner.h.

1342{ return dag2BN_.epsilon(); }

References dag2BN_.

◆ EMHistory()

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

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 1458 of file IBNLearner.h.

1458{ return dag2BN_.history(); }

References dag2BN_.

◆ EMisEnabledEpsilon()

bool gum::learning::IBNLearner::EMisEnabledEpsilon ( ) const
inlineinherited

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

Definition at line 1354 of file IBNLearner.h.

1354{ return dag2BN_.isEnabledEpsilon(); }

References dag2BN_.

◆ EMisEnabledMaxIter()

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

Definition at line 1405 of file IBNLearner.h.

1405{ return dag2BN_.isEnabledMaxIter(); }

References dag2BN_.

◆ EMisEnabledMaxTime()

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

Definition at line 1430 of file IBNLearner.h.

1430{ return dag2BN_.isEnabledMaxTime(); }

References dag2BN_.

◆ EMisEnabledMinEpsilonRate()

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

Definition at line 1381 of file IBNLearner.h.

1381{ return dag2BN_.isEnabledMinEpsilonRate(); }

References dag2BN_.

◆ EMMaxIter()

Size gum::learning::IBNLearner::EMMaxIter ( ) const
inlineinherited

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 1395 of file IBNLearner.h.

1395{ return dag2BN_.maxIter(); }

References dag2BN_.

◆ EMMaxTime()

double gum::learning::IBNLearner::EMMaxTime ( ) const
inlineinherited

@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 1419 of file IBNLearner.h.

1419{ return dag2BN_.maxTime(); }

References dag2BN_.

◆ EMMinEpsilonRate()

double gum::learning::IBNLearner::EMMinEpsilonRate ( ) const
inlineinherited

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 1369 of file IBNLearner.h.

1369{ return dag2BN_.minEpsilonRate(); }

References dag2BN_.

◆ EMnbrIterations()

Size gum::learning::IBNLearner::EMnbrIterations ( ) const
inlineinherited

returns the number of iterations performed by the last EM execution

Definition at line 1452 of file IBNLearner.h.

1452{ return dag2BN_.nbrIterations(); }

References dag2BN_.

◆ EMPeriodSize()

template<typename GUM_SCALAR>
Size gum::learning::IBNLearner::EMPeriodSize ( ) const
inline

Definition at line 1438 of file IBNLearner.h.

1438{ return dag2BN_.periodSize(); }

◆ EMsetEpsilon()

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

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

Definition at line 323 of file BNLearner.h.

323 {
325 return *this;
326 }
void EMsetEpsilon(double eps)
sets the stopping criterion of EM as being the minimal difference between two consecutive log-likelih...

References BNLearner(), and gum::learning::IBNLearner::EMsetEpsilon().

Here is the call graph for this function:

◆ EMsetMaxIter()

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

add a max iteration stopping criterion

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

Definition at line 378 of file BNLearner.h.

378 {
380 return *this;
381 }
void EMsetMaxIter(Size max)
add a max iteration stopping criterion

References BNLearner(), and gum::learning::IBNLearner::EMsetMaxIter().

Here is the call graph for this function:

◆ EMsetMaxTime()

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

add a stopping criterion on timeout

Parameters
timeoutthe timeout in milliseconds
Exceptions
OutOfBoundsif timeout<=0.0

Definition at line 400 of file BNLearner.h.

400 {
402 return *this;
403 }
void EMsetMaxTime(double timeout)
add a stopping criterion on timeout

References BNLearner(), and gum::learning::IBNLearner::EMsetMaxTime().

Here is the call graph for this function:

◆ EMsetMinEpsilonRate()

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

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

Definition at line 352 of file BNLearner.h.

352 {
354 return *this;
355 }
void EMsetMinEpsilonRate(double rate)
sets the stopping criterion of EM as being the minimal log-likelihood's evolution rate

References BNLearner(), and gum::learning::IBNLearner::EMsetMinEpsilonRate().

Here is the call graph for this function:

◆ EMsetPeriodSize()

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

how many samples between 2 stoppings isEnabled

Exceptions
OutOfBoundsif p<1

Definition at line 421 of file BNLearner.h.

421 {
423 return *this;
424 }
void EMsetPeriodSize(Size p)
how many samples between 2 stoppings isEnabled

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

Here is the call graph for this function:

◆ EMsetVerbosity()

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

sets or unsets EM's verbosity

Definition at line 430 of file BNLearner.h.

430 {
432 return *this;
433 }
void EMsetVerbosity(bool v)
sets or unsets EM's verbosity

References BNLearner(), and gum::learning::IBNLearner::EMsetVerbosity().

Here is the call 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 304 of file IBNLearner_inl.h.

References dag2BN_, gum::IApproximationSchemeConfiguration::Undefined, and useEM_.

◆ EMStateApproximationScheme()

ApproximationSchemeSTATE gum::learning::IBNLearner::EMStateApproximationScheme ( ) const
inlineinherited

get the current state of EM

Definition at line 1447 of file IBNLearner.h.

1447 {
1448 return dag2BN_.stateApproximationScheme();
1449 }

References dag2BN_.

◆ EMStateMessage()

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

returns the state of the EM algorithm

Definition at line 310 of file IBNLearner_inl.h.

310 {
311 if (useEM_) return dag2BN_.messageApproximationScheme();
312 else return "EM is currently forbidden. Please enable it with useEM()";
313 }

References dag2BN_, and useEM_.

◆ EMVerbosity()

bool gum::learning::IBNLearner::EMVerbosity ( ) const
inlineinherited

returns the EM's verbosity status

Definition at line 1444 of file IBNLearner.h.

1444{ return dag2BN_.verbosity(); }

References dag2BN_.

◆ enableEpsilon()

void gum::learning::IBNLearner::enableEpsilon ( )
inlineoverridevirtualinherited

Enable stopping criterion on epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1129 of file IBNLearner.h.

1129 {
1130 algoK2_.approximationScheme().enableEpsilon();
1131 greedyHillClimbing_.enableEpsilon();
1132 localSearchWithTabuList_.enableEpsilon();
1133 };

References algoK2_, greedyHillClimbing_, and localSearchWithTabuList_.

◆ enableMaxIter()

void gum::learning::IBNLearner::enableMaxIter ( )
inlineoverridevirtualinherited

Enable stopping criterion on max iterations.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1209 of file IBNLearner.h.

1209 {
1210 algoK2_.approximationScheme().enableMaxIter();
1211 greedyHillClimbing_.enableMaxIter();
1212 localSearchWithTabuList_.enableMaxIter();
1213 };

References algoK2_, greedyHillClimbing_, and localSearchWithTabuList_.

◆ enableMaxTime()

void gum::learning::IBNLearner::enableMaxTime ( )
inlineoverridevirtualinherited

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 1255 of file IBNLearner.h.

1255 {
1256 algoK2_.approximationScheme().enableMaxTime();
1257 greedyHillClimbing_.enableMaxTime();
1258 localSearchWithTabuList_.enableMaxTime();
1259 };

References algoK2_, greedyHillClimbing_, and localSearchWithTabuList_.

◆ enableMinEpsilonRate()

void gum::learning::IBNLearner::enableMinEpsilonRate ( )
inlineoverridevirtualinherited

Enable stopping criterion on epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1169 of file IBNLearner.h.

1169 {
1170 algoK2_.approximationScheme().enableMinEpsilonRate();
1171 greedyHillClimbing_.enableMinEpsilonRate();
1172 localSearchWithTabuList_.enableMinEpsilonRate();
1173 };

References algoK2_, greedyHillClimbing_, and localSearchWithTabuList_.

◆ epsilon()

double gum::learning::IBNLearner::epsilon ( ) const
inlineoverridevirtualinherited

Get the value of epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1116 of file IBNLearner.h.

1116 {
1117 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->epsilon();
1118 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
1119 }

References currentAlgorithm_, and GUM_ERROR.

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

Here is the caller graph for this function:

◆ eraseForbiddenArc() [1/3]

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

Definition at line 574 of file BNLearner.h.

574 {
576 return *this;
577 }
void eraseForbiddenArc(const Arc &arc)

References BNLearner(), and gum::learning::IBNLearner::eraseForbiddenArc().

Here is the call graph for this function:

◆ eraseForbiddenArc() [2/3]

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::eraseForbiddenArc ( const std::string & tail,
const std::string & head )
inline

Definition at line 584 of file BNLearner.h.

584 {
586 return *this;
587 }

References BNLearner(), and gum::learning::IBNLearner::eraseForbiddenArc().

Here is the call graph for this function:

◆ eraseForbiddenArc() [3/3]

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

Definition at line 579 of file BNLearner.h.

579 {
581 return *this;
582 }

References BNLearner(), and gum::learning::IBNLearner::eraseForbiddenArc().

Here is the call graph for this function:

◆ eraseMandatoryArc() [1/3]

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

Definition at line 604 of file BNLearner.h.

604 {
606 return *this;
607 }
void eraseMandatoryArc(const Arc &arc)

References BNLearner(), and gum::learning::IBNLearner::eraseMandatoryArc().

Here is the call graph for this function:

◆ eraseMandatoryArc() [2/3]

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::eraseMandatoryArc ( const std::string & tail,
const std::string & head )
inline

Definition at line 614 of file BNLearner.h.

614 {
616 return *this;
617 }

References BNLearner(), and gum::learning::IBNLearner::eraseMandatoryArc().

Here is the call graph for this function:

◆ eraseMandatoryArc() [3/3]

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

Definition at line 609 of file BNLearner.h.

609 {
611 return *this;
612 }

References BNLearner(), and gum::learning::IBNLearner::eraseMandatoryArc().

Here is the call graph for this function:

◆ eraseNoChildrenNode() [1/2]

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::eraseNoChildrenNode ( const std::string & name)
inline

Definition at line 699 of file BNLearner.h.

699 {
701 return *this;
702 }
void eraseNoChildrenNode(NodeId node)

References BNLearner(), and gum::learning::IBNLearner::eraseNoChildrenNode().

Here is the call graph for this function:

◆ eraseNoChildrenNode() [2/2]

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

Definition at line 694 of file BNLearner.h.

694 {
696 return *this;
697 }

References BNLearner(), and gum::learning::IBNLearner::eraseNoChildrenNode().

Here is the call graph for this function:

◆ eraseNoParentNode() [1/2]

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::eraseNoParentNode ( const std::string & name)
inline

Definition at line 679 of file BNLearner.h.

679 {
681 return *this;
682 }
void eraseNoParentNode(NodeId node)

References BNLearner(), and gum::learning::IBNLearner::eraseNoParentNode().

Here is the call graph for this function:

◆ eraseNoParentNode() [2/2]

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

Definition at line 674 of file BNLearner.h.

674 {
676 return *this;
677 }

References BNLearner(), and gum::learning::IBNLearner::eraseNoParentNode().

Here is the call graph for this function:

◆ erasePossibleEdge() [1/3]

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

Definition at line 634 of file BNLearner.h.

634 {
636 return *this;
637 }
void erasePossibleEdge(const Edge &edge)

References BNLearner(), and gum::learning::IBNLearner::erasePossibleEdge().

Here is the call graph for this function:

◆ erasePossibleEdge() [2/3]

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::erasePossibleEdge ( const std::string & tail,
const std::string & head )
inline

Definition at line 644 of file BNLearner.h.

644 {
646 return *this;
647 }

References BNLearner(), and gum::learning::IBNLearner::erasePossibleEdge().

Here is the call graph for this function:

◆ erasePossibleEdge() [3/3]

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

Definition at line 639 of file BNLearner.h.

639 {
641 return *this;
642 }

References BNLearner(), and gum::learning::IBNLearner::erasePossibleEdge().

Here is the call graph for this function:

◆ forbidEM()

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

prevent using the EM algorithm for parameter learning

Definition at line 310 of file BNLearner.h.

310 {
312 return *this;
313 }
void forbidEM()
prevent using the EM algorithm for parameter learning

References BNLearner(), and gum::learning::IBNLearner::forbidEM().

Here is the call graph for this function:

◆ G2() [1/2]

std::pair< double, double > gum::learning::IBNLearner::G2 ( const std::string & name1,
const std::string & 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 988 of file IBNLearner.cpp.

990 {
991 std::vector< NodeId > knowingIds;
992 std::transform(knowing.begin(),
993 knowing.end(),
994 std::back_inserter(knowingIds),
995 [this](const std::string& c) { return this->idFromName(c); });
996 return G2(idFromName(name1), idFromName(name2), knowingIds);
997 }
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:

◆ G2() [2/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 982 of file IBNLearner.cpp.

982 {
983 createPrior_();
984 gum::learning::IndepTestG2 g2score(scoreDatabase_.parser(), *prior_, databaseRanges());
985 return g2score.statistics(id1, id2, knowing);
986 }

References createPrior_(), databaseRanges(), 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:

◆ getNumberOfThreads()

virtual Size gum::ThreadNumberManager::getNumberOfThreads ( ) const
virtualinherited

◆ getPriorType_()

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

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

Definition at line 518 of file IBNLearner_inl.h.

518 {
519 switch (priorType_) {
521 case NO_prior : return PriorType::NoPriorType;
525 case BDEU : return PriorType::BDeuPriorType;
526 default :
527 GUM_ERROR(OperationNotAllowed,
528 "IBNLearner getPriorType does "
529 "not support yet this prior")
530 }
531 }
BNLearnerPriorType priorType_
the a priorselected for the score and parameters
Definition IBNLearner.h:956
BNLearnerPriorType
an enumeration to select the prior
Definition IBNLearner.h:108

References BDEU, gum::learning::BDeuPriorType, DIRICHLET_FROM_BAYESNET, DIRICHLET_FROM_DATABASE, gum::learning::DirichletPriorType, GUM_ERROR, NO_prior, gum::learning::NoPriorType, priorType_, SMOOTHING, and gum::learning::SmoothingPriorType.

Referenced by checkScorePriorCompatibility().

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 315 of file IBNLearner_inl.h.

315 {
316 return scoreDatabase_.databaseTable().hasMissingValues();
317 }

References scoreDatabase_.

Referenced by rawPseudoCount().

Here is the caller graph for this function:

◆ history()

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1316 of file IBNLearner.h.

1316 {
1317 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->history();
1318 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
1319 }

References currentAlgorithm_, and GUM_ERROR.

◆ idFromName()

INLINE NodeId gum::learning::IBNLearner::idFromName ( const std::string & 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 135 of file IBNLearner_inl.h.

135 {
136 return scoreDatabase_.idFromName(var_name);
137 }

References scoreDatabase_.

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

Here is the caller graph for this function:

◆ initialDAG()

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

returns the initial DAG structure

Definition at line 165 of file IBNLearner_inl.h.

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

References initialDag_.

◆ isConstraintBased()

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

Definition at line 704 of file BNLearner.h.

References gum::learning::IBNLearner::isConstraintBased().

Here is the call graph for this function:

◆ isCSVFileName_()

void gum::learning::IBNLearner::isCSVFileName_ ( const std::string & filename)
staticprotectedinherited

checks whether the extension of a CSV filename is correct

Definition at line 426 of file IBNLearner.cpp.

426 {
427 // get the extension of the file
428
429 if (auto filename_size = Size(filename.size()); filename_size < 4) {
430 GUM_ERROR(FormatNotFound,
431 "IBNLearner could not determine the "
432 "file type of the database")
433 }
434
435 auto extension = filename.substr(filename.size() - 4);
436 std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
437
438 if (extension != ".csv") {
439 GUM_ERROR(OperationNotAllowed, "IBNLearner does not support yet this type of database file")
440 }
441 }

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()

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1137 of file IBNLearner.h.

1137 {
1138 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->isEnabledEpsilon();
1139 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
1140 }

References currentAlgorithm_, and GUM_ERROR.

◆ isEnabledMaxIter()

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1217 of file IBNLearner.h.

1217 {
1218 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->isEnabledMaxIter();
1219 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
1220 }

References currentAlgorithm_, and GUM_ERROR.

◆ isEnabledMaxTime()

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1263 of file IBNLearner.h.

1263 {
1264 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->isEnabledMaxTime();
1265 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
1266 }

References currentAlgorithm_, and GUM_ERROR.

◆ isEnabledMinEpsilonRate()

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1177 of file IBNLearner.h.

1177 {
1178 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->isEnabledMinEpsilonRate();
1179 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
1180 }

References currentAlgorithm_, and GUM_ERROR.

◆ isGumNumberOfThreadsOverriden()

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

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

Implements gum::IThreadNumberManager.

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

Here is the caller graph for this function:

◆ isScoreBased()

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

Definition at line 706 of file BNLearner.h.

706{ return IBNLearner::isScoreBased(); }
bool isScoreBased() const
indicate if the selected algorithm is score-based
Definition IBNLearner.h:788

References gum::learning::IBNLearner::isScoreBased().

Here is the call graph for this function:

◆ isUsingEM()

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

indicates whether we use EM for parameter learning

Definition at line 295 of file IBNLearner_inl.h.

295{ 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 227 of file IBNLearner_inl.h.

227 {
228 return algoMiic_.latentVariables();
229 }
Miic algoMiic_
the Constraint MIIC algorithm

References algoMiic_.

◆ learnBN()

template<typename 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 702 of file IBNLearner.cpp.

702 {
703 // create the score and the prior
704 createPrior_();
705 createScore_();
706
707 return learnDag_();
708 }
DAG learnDag_()
returns the DAG learnt
void createScore_()
create the score used for learning

References createPrior_(), createScore_(), and learnDag_().

Here is the call graph for this function:

◆ learnDag_()

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

returns the DAG learnt

Definition at line 729 of file IBNLearner.cpp.

729 {
730 // check that the database does not contain any missing value
731 if (scoreDatabase_.databaseTable().hasMissingValues()
732 || ((priorDatabase_ != nullptr)
734 && priorDatabase_->databaseTable().hasMissingValues())) {
735 GUM_ERROR(MissingValueInDatabase,
736 "For the moment, the BNLearner is unable to cope "
737 "with missing values in databases")
738 }
739 // add the mandatory arcs to the initial dag and remove the forbidden ones
740 // from the initial graph
741 DAG init_graph = initialDag_;
742
743 for (const auto& arc: constraintMandatoryArcs_.arcs()) {
744 if (!init_graph.exists(arc.tail())) init_graph.addNodeWithId(arc.tail());
745
746 if (!init_graph.exists(arc.head())) init_graph.addNodeWithId(arc.head());
747
748 init_graph.addArc(arc.tail(), arc.head());
749 }
750
751 for (const auto& arc: constraintForbiddenArcs_.arcs())
752 init_graph.eraseArc(arc);
753
754
755 switch (selectedAlgo_) {
756 // ========================================================================
757 case AlgoType::MIIC : {
758 BNLearnerListener listener(this, algoMiic_);
759 // create the mixedGraph and the corrected mutual information
760 MixedGraph mgraph = this->prepareMiic_();
761
762 return algoMiic_.learnStructure(*mutualInfo_, mgraph);
763 }
764
765 // ========================================================================
767 BNLearnerListener listener(this, greedyHillClimbing_);
768 StructuralConstraintSetStatic< StructuralConstraintMandatoryArcs,
769 StructuralConstraintForbiddenArcs,
770 StructuralConstraintPossibleEdges,
771 StructuralConstraintSliceOrder,
772 StructuralConstraintNoParentNodes,
773 StructuralConstraintNoChildrenNodes >
774 gen_constraint;
775 static_cast< StructuralConstraintMandatoryArcs& >(gen_constraint)
777 static_cast< StructuralConstraintForbiddenArcs& >(gen_constraint)
779 static_cast< StructuralConstraintPossibleEdges& >(gen_constraint)
781 static_cast< StructuralConstraintSliceOrder& >(gen_constraint) = constraintSliceOrder_;
782 static_cast< StructuralConstraintNoParentNodes& >(gen_constraint)
784 static_cast< StructuralConstraintNoChildrenNodes& >(gen_constraint)
786
787 GraphChangesGenerator4DiGraph op_set(gen_constraint);
788
789 StructuralConstraintSetStatic< StructuralConstraintIndegree, StructuralConstraintDAG >
790 sel_constraint;
791 static_cast< StructuralConstraintIndegree& >(sel_constraint) = constraintIndegree_;
792
793 GraphChangesSelector4DiGraph selector(*score_, sel_constraint, op_set);
794
795 return greedyHillClimbing_.learnStructure(selector, init_graph);
796 }
797
798 // ========================================================================
800 BNLearnerListener listener(this, localSearchWithTabuList_);
801 StructuralConstraintSetStatic< StructuralConstraintMandatoryArcs,
802 StructuralConstraintForbiddenArcs,
803 StructuralConstraintPossibleEdges,
804 StructuralConstraintSliceOrder,
805 StructuralConstraintNoParentNodes,
806 StructuralConstraintNoChildrenNodes >
807 gen_constraint;
808 static_cast< StructuralConstraintMandatoryArcs& >(gen_constraint)
810 static_cast< StructuralConstraintForbiddenArcs& >(gen_constraint)
812 static_cast< StructuralConstraintPossibleEdges& >(gen_constraint)
814 static_cast< StructuralConstraintSliceOrder& >(gen_constraint) = constraintSliceOrder_;
815 static_cast< StructuralConstraintNoParentNodes& >(gen_constraint)
817 static_cast< StructuralConstraintNoChildrenNodes& >(gen_constraint)
819
820 GraphChangesGenerator4DiGraph op_set(gen_constraint);
821
822 StructuralConstraintSetStatic< StructuralConstraintTabuList,
823 StructuralConstraintIndegree,
824 StructuralConstraintDAG >
825 sel_constraint;
826 static_cast< StructuralConstraintTabuList& >(sel_constraint) = constraintTabuList_;
827 static_cast< StructuralConstraintIndegree& >(sel_constraint) = constraintIndegree_;
828
829 GraphChangesSelector4DiGraph selector(*score_, sel_constraint, op_set);
830
831 return localSearchWithTabuList_.learnStructure(selector, init_graph);
832 }
833
834 // ========================================================================
835 case AlgoType::K2 : {
836 BNLearnerListener listener(this, algoK2_.approximationScheme());
837 StructuralConstraintSetStatic< StructuralConstraintMandatoryArcs,
838 StructuralConstraintForbiddenArcs,
839 StructuralConstraintPossibleEdges,
840 StructuralConstraintNoParentNodes,
841 StructuralConstraintNoChildrenNodes >
842 gen_constraint;
843 static_cast< StructuralConstraintMandatoryArcs& >(gen_constraint)
845 static_cast< StructuralConstraintForbiddenArcs& >(gen_constraint)
847 static_cast< StructuralConstraintPossibleEdges& >(gen_constraint)
849 ;
850 static_cast< StructuralConstraintNoParentNodes& >(gen_constraint)
852 ;
853 static_cast< StructuralConstraintNoChildrenNodes& >(gen_constraint)
855
856 GraphChangesGenerator4K2 op_set(gen_constraint);
857
858 // if some mandatory arcs are incompatible with the order, use a DAG
859 // constraint instead of a DiGraph constraint to avoid cycles
860 const ArcSet& mandatory_arcs
861 = static_cast< StructuralConstraintMandatoryArcs& >(gen_constraint).arcs();
862 const Sequence< NodeId >& order = algoK2_.order();
863 bool order_compatible = true;
864
865 for (const auto& arc: mandatory_arcs) {
866 if (order.pos(arc.tail()) >= order.pos(arc.head())) {
867 order_compatible = false;
868 break;
869 }
870 }
871
872 if (order_compatible) {
873 StructuralConstraintSetStatic< StructuralConstraintIndegree, StructuralConstraintDiGraph >
874 sel_constraint;
875 static_cast< StructuralConstraintIndegree& >(sel_constraint) = constraintIndegree_;
876
877 GraphChangesSelector4DiGraph selector(*score_, sel_constraint, op_set);
878
879 return algoK2_.learnStructure(selector, init_graph);
880 } else {
881 StructuralConstraintSetStatic< StructuralConstraintIndegree, StructuralConstraintDAG >
882 sel_constraint;
883 static_cast< StructuralConstraintIndegree& >(sel_constraint) = constraintIndegree_;
884
885 GraphChangesSelector4DiGraph selector(*score_, sel_constraint, op_set);
886
887 return algoK2_.learnStructure(selector, init_graph);
888 }
889 }
890
891 // ========================================================================
892 default :
893 GUM_ERROR(OperationNotAllowed,
894 "the learnDAG method has not been implemented for this "
895 "learning algorithm")
896 }
897 }
StructuralConstraintPossibleEdges constraintPossibleEdges_
the constraint on possible Edges
Definition IBNLearner.h:979
StructuralConstraintNoParentNodes constraintNoParentNodes_
the constraint on no parent nodes
Definition IBNLearner.h:985
AlgoType selectedAlgo_
the selected learning algorithm
Definition IBNLearner.h:992
StructuralConstraintNoChildrenNodes constraintNoChildrenNodes_
the constraint on no children nodes
Definition IBNLearner.h:988
Database * priorDatabase_
the database used by the Dirichlet a priori
StructuralConstraintIndegree constraintIndegree_
the constraint for indegrees
Definition IBNLearner.h:970
StructuralConstraintMandatoryArcs constraintMandatoryArcs_
the constraint on mandatory arcs
Definition IBNLearner.h:982
StructuralConstraintForbiddenArcs constraintForbiddenArcs_
the constraint on forbidden arcs
Definition IBNLearner.h:976
StructuralConstraintTabuList constraintTabuList_
the constraint for tabu lists
Definition IBNLearner.h:973
MixedGraph prepareMiic_()
prepares the initial graph for miic
StructuralConstraintSliceOrder constraintSliceOrder_
the constraint for 2TBNs
Definition IBNLearner.h:967
Set< Arc > ArcSet
Some typdefs and define for shortcuts ...

References gum::DAG::addArc(), gum::NodeGraphPart::addNodeWithId(), algoK2_, algoMiic_, constraintForbiddenArcs_, constraintIndegree_, constraintMandatoryArcs_, constraintNoChildrenNodes_, constraintNoParentNodes_, constraintPossibleEdges_, constraintSliceOrder_, constraintTabuList_, DIRICHLET_FROM_DATABASE, gum::ArcGraphPart::eraseArc(), gum::NodeGraphPart::exists(), GREEDY_HILL_CLIMBING, greedyHillClimbing_, GUM_ERROR, initialDag_, K2, LOCAL_SEARCH_WITH_TABU_LIST, localSearchWithTabuList_, MIIC, mutualInfo_, gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::pos(), prepareMiic_(), priorDatabase_, priorType_, score_, scoreDatabase_, and selectedAlgo_.

Referenced by learnDAG().

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

◆ learnParameters() [1/3]

template<typename 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<typename 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<typename 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 683 of file IBNLearner.cpp.

683 {
685 GUM_ERROR(OperationNotAllowed,
686 "Score-based algorithms do not build PDAG. Please use a constraint-based "
687 "algorithm instead")
688 }
689 // check that the database does not contain any missing value
690 if (scoreDatabase_.databaseTable().hasMissingValues()) {
691 GUM_ERROR(MissingValueInDatabase,
692 "For the moment, the BNLearner is unable to learn "
693 << "structures with missing values in databases")
694 }
695
696 BNLearnerListener listener(this, algoMiic_);
697 // create the mixedGraph_constraint_MandatoryArcs.arcs
698 MixedGraph mgraph = this->prepareMiic_();
699 return algoMiic_.learnPDAG(*mutualInfo_, mgraph);
700 }

References algoMiic_, GUM_ERROR, MIIC, mutualInfo_, prepareMiic_(), scoreDatabase_, and selectedAlgo_.

Here is the call 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 999 of file IBNLearner.cpp.

1000 {
1001 createPrior_();
1002 gum::learning::ScoreLog2Likelihood ll2score(scoreDatabase_.parser(), *prior_, databaseRanges());
1003
1004 std::vector< NodeId > total(vars);
1005 total.insert(total.end(), knowing.begin(), knowing.end());
1006 double LLtotal = ll2score.score(IdCondSet(total, false, true));
1007 if (knowing.size() == (Size)0) {
1008 return LLtotal;
1009 } else {
1010 double LLknw = ll2score.score(IdCondSet(knowing, false, true));
1011 return LLtotal - LLknw;
1012 }
1013 }

References createPrior_(), databaseRanges(), 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 1015 of file IBNLearner.cpp.

1016 {
1017 std::vector< NodeId > ids;
1018 std::vector< NodeId > knowingIds;
1019
1020 auto mapper = [this](const std::string& c) { return this->idFromName(c); };
1021
1022 std::transform(vars.begin(), vars.end(), std::back_inserter(ids), mapper);
1023 std::transform(knowing.begin(), knowing.end(), std::back_inserter(knowingIds), mapper);
1024
1025 return logLikelihood(ids, knowingIds);
1026 }
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()

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1196 of file IBNLearner.h.

1196 {
1197 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->maxIter();
1198 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
1199 }

References currentAlgorithm_, and GUM_ERROR.

◆ maxTime()

double gum::learning::IBNLearner::maxTime ( ) const
inlineoverridevirtualinherited

returns the timeout (in seconds)

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1237 of file IBNLearner.h.

1237 {
1238 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->maxTime();
1239 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
1240 }

References currentAlgorithm_, and GUM_ERROR.

◆ messageApproximationScheme()

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

Returns the approximation scheme message.

Returns
Returns the approximation scheme message.

Definition at line 59 of file IApproximationSchemeConfiguration_inl.h.

59 {
60 std::stringstream s;
61
62 switch (stateApproximationScheme()) {
63 case ApproximationSchemeSTATE::Continue : s << "in progress"; break;
64
65 case ApproximationSchemeSTATE::Epsilon : s << "stopped with epsilon=" << epsilon(); break;
66
67 case ApproximationSchemeSTATE::Rate : s << "stopped with rate=" << minEpsilonRate(); break;
68
69 case ApproximationSchemeSTATE::Limit : s << "stopped with max iteration=" << maxIter(); break;
70
71 case ApproximationSchemeSTATE::TimeLimit : s << "stopped with timeout=" << maxTime(); break;
72
73 case ApproximationSchemeSTATE::Stopped : s << "stopped on request"; break;
74
75 case ApproximationSchemeSTATE::Undefined : s << "undefined state"; break;
76 };
77
78 return s.str();
79 }
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::credal::InferenceEngine< GUM_SCALAR >::getApproximationSchemeMsg(), and gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::stateApproximationScheme().

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

◆ minEpsilonRate()

double gum::learning::IBNLearner::minEpsilonRate ( ) const
inlineoverridevirtualinherited

Get the value of the minimal epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1156 of file IBNLearner.h.

1156 {
1157 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->minEpsilonRate();
1158 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
1159 }

References currentAlgorithm_, and GUM_ERROR.

◆ mutualInformation() [1/2]

double gum::learning::IBNLearner::mutualInformation ( const std::string & var1,
const std::string & 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 1076 of file IBNLearner.cpp.

1078 {
1079 std::vector< NodeId > knowingIds;
1080
1081 auto mapper = [this](const std::string& c) { return this->idFromName(c); };
1082
1083 std::transform(knowing.begin(), knowing.end(), std::back_inserter(knowingIds), mapper);
1084
1085 return mutualInformation(this->idFromName(var1), this->idFromName(var2), knowingIds);
1086 }
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:

◆ mutualInformation() [2/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 1065 of file IBNLearner.cpp.

1067 {
1068 const auto prior = NoPrior(scoreDatabase_.databaseTable(), scoreDatabase_.nodeId2Columns());
1069 gum::learning::CorrectedMutualInformation cmi(scoreDatabase_.parser(), prior, databaseRanges());
1070 cmi.useNoCorr();
1071
1072 if (knowing.size() == (Size)0) return cmi.score(id1, id2) / scoreDatabase_.weight();
1073 else return cmi.score(id1, id2, knowing) / scoreDatabase_.weight();
1074 }

References databaseRanges(), gum::learning::CorrectedMutualInformation::score(), scoreDatabase_, and gum::learning::CorrectedMutualInformation::useNoCorr().

Referenced by mutualInformation().

Here is the call graph for this function:
Here is the caller 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 140 of file IBNLearner_inl.h.

140 {
141 return scoreDatabase_.nameFromId(id);
142 }

References scoreDatabase_.

◆ 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 534 of file IBNLearner_inl.h.

534 {
535 return scoreDatabase_.names();
536 }

References scoreDatabase_.

◆ nbCols()

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

Definition at line 565 of file IBNLearner_inl.h.

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

References scoreDatabase_.

◆ nbrIterations()

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1310 of file IBNLearner.h.

1310 {
1311 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->nbrIterations();
1312 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
1313 }

References currentAlgorithm_, and GUM_ERROR.

◆ nbRows()

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

Definition at line 567 of file IBNLearner_inl.h.

567{ return scoreDatabase_.databaseTable().size(); }

References scoreDatabase_.

◆ operator=() [1/2]

template<typename 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<typename 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()

Size gum::learning::IBNLearner::periodSize ( ) const
inlineoverridevirtualinherited

how many samples between 2 stopping isEnableds

Exceptions
OutOfBoundsif p<1

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1279 of file IBNLearner.h.

1279 {
1280 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->periodSize();
1281 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
1282 }

References currentAlgorithm_, and GUM_ERROR.

◆ prepareMiic_()

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

prepares the initial graph for miic

Definition at line 594 of file IBNLearner.cpp.

594 {
595 // Initialize the mixed graph to the fully connected graph
596 MixedGraph mgraph;
597 DiGraph forbiddenGraph;
598 DAG mandatoryGraph;
599
600 // GUM_CHECKPOINT
601 for (Size i = 0; i < scoreDatabase_.databaseTable().nbVariables(); ++i) {
602 mgraph.addNodeWithId(i);
603 forbiddenGraph.addNodeWithId(i);
604 mandatoryGraph.addNodeWithId(i);
605 }
606
607 const EdgeSet& possible_edges = constraintPossibleEdges_.edges();
608
609 if (possible_edges.empty()) {
610 for (const NodeId i: mgraph.nodes()) {
611 for (NodeId j = 0; j < i; ++j) {
612 // contiguous nodeIds !
613 mgraph.addEdge(j, i);
614 }
615 }
616 } else {
617 for (const auto& edge: possible_edges) {
618 mgraph.addEdge(edge.first(), edge.second());
619 }
620 }
621 // GUM_CHECKPOINT
622
623 // translating the mandatory arcs for constraintMiic
624 HashTable< std::pair< NodeId, NodeId >, char > initial_marks;
625 const ArcSet& mandatory_arcs = constraintMandatoryArcs_.arcs();
626
627 // GUM_CHECKPOINT
628 for (const auto& arc: mandatory_arcs) {
629 mandatoryGraph.addArc(arc.tail(), arc.head());
630 forbiddenGraph.addArc(arc.head(), arc.head());
631 }
632
633 // GUM_CHECKPOINT
634 // translating the forbidden arcs for constraintMiic
635 const ArcSet& forbidden_arcs = constraintForbiddenArcs_.arcs();
636 for (const auto& arc: forbidden_arcs) {
637 forbiddenGraph.addArc(arc.tail(), arc.head());
638 }
639
640 // GUM_CHECKPOINT
641 const gum::NodeProperty< gum::Size > sliceOrder = constraintSliceOrder_.sliceOrder();
642 gum::NodeProperty< gum::Size > copyOrder = gum::HashTable(sliceOrder);
643 for (const auto& [n1, r1]: sliceOrder) {
644 for (const auto& [n2, r2]: copyOrder) {
645 if (r1 > r2) {
646 forbiddenGraph.addArc(n1, n2);
647 // initial_marks.insert({n1, n2}, '-');
648 } else if (r2 > r1) {
649 forbiddenGraph.addArc(n2, n1);
650 // initial_marks.insert({n2, n1}, '-');
651 }
652 }
653 copyOrder.erase(n1);
654 }
655
656 for (const auto node: constraintNoParentNodes_.nodes()) {
657 for (const auto node2: mgraph.nodes()) {
658 if (node != node2) { forbiddenGraph.addArc(node2, node); }
659 }
660 }
661
662 for (const auto node: constraintNoChildrenNodes_.nodes()) {
663 for (const auto node2: mgraph.nodes()) {
664 if (node != node2) { forbiddenGraph.addArc(node, node2); }
665 }
666 }
667
668 // GUM_CHECKPOINT
669 algoMiic_.setMaxIndegree(constraintIndegree_.maxIndegree());
670 algoMiic_.addConstraints(initial_marks);
671 algoMiic_.setMandatoryGraph(mandatoryGraph);
672 algoMiic_.setForbiddenGraph(forbiddenGraph);
673
674 // GUM_CHECKPOINT
675 // create the mutual entropy object
676 // if ( _mutual_info_ == nullptr) { this->useNMLCorrection(); }
678
679 // GUM_CHECKPOINT
680 return mgraph;
681 }
void createCorrectedMutualInformation_()
create the Corrected Mutual Information instance for Miic
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::DAG::addArc(), gum::DiGraph::addArc(), gum::UndiGraph::addEdge(), gum::NodeGraphPart::addNodeWithId(), algoMiic_, constraintForbiddenArcs_, constraintIndegree_, constraintMandatoryArcs_, constraintNoChildrenNodes_, constraintNoParentNodes_, constraintPossibleEdges_, constraintSliceOrder_, createCorrectedMutualInformation_(), gum::Set< Key >::empty(), gum::NodeGraphPart::nodes(), and scoreDatabase_.

Referenced by learnDag_(), and learnPDAG().

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

◆ prepareSimpleMiic_()

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

prepares the initial graph for Simple Miic

◆ 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 a std::vector<double> containing the contingency table

Definition at line 1106 of file IBNLearner.cpp.

1106 {
1107 if (this->hasMissingValues()) {
1108 GUM_ERROR(MissingValueInDatabase,
1109 "BNLearner cannot compute pseudo-counts with missing values in the database")
1110 }
1111 if (vars.empty()) {
1112 GUM_ERROR(OutOfBounds, "BNLearner::rawPseudoCount called with an empty vector of variables")
1113 }
1114 Tensor< double > res;
1115
1116 createPrior_();
1117 gum::learning::PseudoCount count(scoreDatabase_.parser(), *prior_, databaseRanges());
1118 return count.get(vars);
1119 }
bool hasMissingValues() const
returns true if the learner's database has missing values

References createPrior_(), databaseRanges(), gum::learning::PseudoCount::get(), GUM_ERROR, hasMissingValues(), prior_, and scoreDatabase_.

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 1121 of file IBNLearner.cpp.

1121 {
1122 std::vector< NodeId > ids;
1123
1124 auto mapper = [this](const std::string& c) { return this->idFromName(c); };
1125
1126 std::transform(vars.begin(), vars.end(), std::back_inserter(ids), mapper);
1127 return rawPseudoCount(ids);
1128 }
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_ ( const std::string & filename,
const std::vector< std::string > & missing_symbols )
staticprotectedinherited

reads a file and returns a databaseVectInRam

Definition at line 443 of file IBNLearner.cpp.

444 {
445 // get the extension of the file
446 isCSVFileName_(filename);
447
448 DBInitializerFromCSV initializer(filename);
449
450 const auto& var_names = initializer.variableNames();
451 const std::size_t nb_vars = var_names.size();
452
453 DBTranslatorSet translator_set;
454 DBTranslator4LabelizedVariable translator(missing_symbols);
455 for (std::size_t i = 0; i < nb_vars; ++i) {
456 translator_set.insertTranslator(translator, i);
457 }
458
459 DatabaseTable database(missing_symbols, translator_set);
460 database.setVariableNames(initializer.variableNames());
461 initializer.fillDatabase(database);
462
463 database.reorder();
464
465 return database;
466 }
static void isCSVFileName_(const std::string &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_(), 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 155 of file IBNLearner_inl.h.

155 {
156 return scoreDatabase_.weight(i);
157 }

References scoreDatabase_.

◆ score() [1/2]

double gum::learning::IBNLearner::score ( const std::string & 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 1095 of file IBNLearner.cpp.

1095 {
1096 auto mapper = [this](const std::string& c) { return this->idFromName(c); };
1097
1098 const NodeId id = this->idFromName(var);
1099 std::vector< NodeId > knowingIds;
1100 knowingIds.reserve(knowing.size());
1101 std::transform(knowing.begin(), knowing.end(), std::back_inserter(knowingIds), mapper);
1102
1103 return score(id, knowingIds);
1104 }
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:

◆ score() [2/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 1088 of file IBNLearner.cpp.

1088 {
1089 createPrior_();
1090 createScore_();
1091
1092 return score_->score(var, knowing);
1093 }

References createPrior_(), createScore_(), and score_.

Referenced by score(), and useDatabaseRanges().

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

◆ setCurrentApproximationScheme()

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

{@ /// distribute signals

Definition at line 1082 of file IBNLearner.h.

1082 {
1083 currentAlgorithm_ = approximationScheme;
1084 }

References currentAlgorithm_.

Referenced by gum::learning::BNLearnerListener::BNLearnerListener(), 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 145 of file IBNLearner_inl.h.

145 {
146 scoreDatabase_.setDatabaseWeight(new_weight);
147 }

References scoreDatabase_.

◆ setEpsilon()

void gum::learning::IBNLearner::setEpsilon ( double eps)
inlineoverridevirtualinherited

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 1109 of file IBNLearner.h.

1109 {
1110 algoK2_.approximationScheme().setEpsilon(eps);
1111 greedyHillClimbing_.setEpsilon(eps);
1112 localSearchWithTabuList_.setEpsilon(eps);
1113 };

References algoK2_, greedyHillClimbing_, and localSearchWithTabuList_.

◆ setForbiddenArcs()

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

Definition at line 554 of file BNLearner.h.

554 {
556 return *this;
557 }
void setForbiddenArcs(const ArcSet &set)
assign a set of forbidden arcs

References BNLearner(), and gum::learning::IBNLearner::setForbiddenArcs().

Here is the call graph for this function:

◆ setInitialDAG()

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

Definition at line 236 of file BNLearner.h.

236 {
238 return *this;
239 }
void setInitialDAG(const DAG &)
sets an initial DAG structure

References BNLearner(), setInitialDAG(), and gum::learning::IBNLearner::setInitialDAG().

Referenced by setInitialDAG().

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

◆ setMandatoryArcs()

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

Definition at line 649 of file BNLearner.h.

649 {
651 return *this;
652 }
void setMandatoryArcs(const ArcSet &set)
assign a set of mandatory arcs

References BNLearner(), and gum::learning::IBNLearner::setMandatoryArcs().

Here is the call graph for this function:

◆ setMaxIndegree()

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

Definition at line 538 of file BNLearner.h.

538 {
540 return *this;
541 }
void setMaxIndegree(Size max_indegree)
sets the max indegree

References BNLearner(), and gum::learning::IBNLearner::setMaxIndegree().

Here is the call graph for this function:

◆ setMaxIter()

void gum::learning::IBNLearner::setMaxIter ( Size max)
inlineoverridevirtualinherited

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 1189 of file IBNLearner.h.

1189 {
1190 algoK2_.approximationScheme().setMaxIter(max);
1191 greedyHillClimbing_.setMaxIter(max);
1192 localSearchWithTabuList_.setMaxIter(max);
1193 };

References algoK2_, greedyHillClimbing_, and localSearchWithTabuList_.

◆ setMaxTime()

void gum::learning::IBNLearner::setMaxTime ( double timeout)
inlineoverridevirtualinherited

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 1230 of file IBNLearner.h.

1230 {
1231 algoK2_.approximationScheme().setMaxTime(timeout);
1232 greedyHillClimbing_.setMaxTime(timeout);
1233 localSearchWithTabuList_.setMaxTime(timeout);
1234 }

References algoK2_, greedyHillClimbing_, and localSearchWithTabuList_.

◆ setMinEpsilonRate()

void gum::learning::IBNLearner::setMinEpsilonRate ( double rate)
inlineoverridevirtualinherited

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 1149 of file IBNLearner.h.

1149 {
1150 algoK2_.approximationScheme().setMinEpsilonRate(rate);
1151 greedyHillClimbing_.setMinEpsilonRate(rate);
1152 localSearchWithTabuList_.setMinEpsilonRate(rate);
1153 };

References algoK2_, greedyHillClimbing_, and localSearchWithTabuList_.

◆ 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

Reimplemented from gum::ThreadNumberManager.

Definition at line 570 of file IBNLearner_inl.h.

570 {
572 if (score_ != nullptr) score_->setNumberOfThreads(nb);
573 }
virtual void setNumberOfThreads(Size nb)
sets the number max of threads to be used by the class containing this ThreadNumberManager

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

Here is the call graph for this function:

◆ setPeriodSize()

void gum::learning::IBNLearner::setPeriodSize ( Size p)
inlineoverridevirtualinherited

how many samples between 2 stopping isEnableds

Exceptions
OutOfBoundsif p<1

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1273 of file IBNLearner.h.

1273 {
1274 algoK2_.approximationScheme().setPeriodSize(p);
1275 greedyHillClimbing_.setPeriodSize(p);
1276 localSearchWithTabuList_.setPeriodSize(p);
1277 };

References algoK2_, greedyHillClimbing_, and localSearchWithTabuList_.

◆ setPossibleEdges()

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

Definition at line 654 of file BNLearner.h.

654 {
656 return *this;
657 }
void setPossibleEdges(const EdgeSet &set)
assign a set of possible edges

References BNLearner(), and gum::learning::IBNLearner::setPossibleEdges().

Here is the call graph for this function:

◆ setPossibleSkeleton()

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

Definition at line 659 of file BNLearner.h.

659 {
661 return *this;
662 }
void setPossibleSkeleton(const UndiGraph &skeleton)
assign a set of possible edges

References BNLearner(), and gum::learning::IBNLearner::setPossibleSkeleton().

Here is the call 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 150 of file IBNLearner_inl.h.

150 {
151 scoreDatabase_.setWeight(i, new_weight);
152 }

References scoreDatabase_.

◆ setSliceOrder() [1/2]

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

Definition at line 543 of file BNLearner.h.

543 {
545 return *this;
546 }
void setSliceOrder(const NodeProperty< NodeId > &slice_order)
sets a partial order on the nodes

References BNLearner(), and gum::learning::IBNLearner::setSliceOrder().

Here is the call graph for this function:

◆ setSliceOrder() [2/2]

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

Definition at line 549 of file BNLearner.h.

549 {
551 return *this;
552 }

References gum::learning::IBNLearner::setSliceOrder().

Here is the call graph for this function:

◆ setVerbosity()

void gum::learning::IBNLearner::setVerbosity ( bool v)
inlineoverridevirtualinherited

verbosity

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1288 of file IBNLearner.h.

1288 {
1289 algoK2_.approximationScheme().setVerbosity(v);
1290 greedyHillClimbing_.setVerbosity(v);
1291 localSearchWithTabuList_.setVerbosity(v);
1292 };

References algoK2_, greedyHillClimbing_, and localSearchWithTabuList_.

◆ state()

template<typename 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()

ApproximationSchemeSTATE gum::learning::IBNLearner::stateApproximationScheme ( ) const
inlineoverridevirtualinherited

history

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1304 of file IBNLearner.h.

1304 {
1305 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->stateApproximationScheme();
1306 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
1307 }

References currentAlgorithm_, and GUM_ERROR.

◆ toString()

template<typename 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:

◆ useBDeuPrior()

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useBDeuPrior ( double weight = 1.0)
inline

Definition at line 470 of file BNLearner.h.

470 {
472 return *this;
473 }
void useBDeuPrior(double weight=1.0)
use the BDeu prior

References BNLearner(), and gum::learning::IBNLearner::useBDeuPrior().

Here is the call 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 924 of file IBNLearner.cpp.

925 {
926 if (k_fold == 0) { GUM_ERROR(OutOfBounds, "K-fold cross validation with k=0 is forbidden") }
927
928 if (learning_fold >= k_fold) {
929 GUM_ERROR(OutOfBounds,
930 "In " << k_fold << "-fold cross validation, the learning "
931 << "fold should be strictly lower than " << k_fold
932 << " but, here, it is equal to " << learning_fold)
933 }
934
935 const std::size_t db_size = scoreDatabase_.databaseTable().nbRows();
936 if (k_fold >= db_size) {
937 GUM_ERROR(OutOfBounds,
938 "In " << k_fold << "-fold cross validation, the database's "
939 << "size should be strictly greater than " << k_fold
940 << " but, here, the database has only " << db_size << "rows")
941 }
942
943 // create the ranges of rows of the test database
944 const std::size_t foldSize = db_size / k_fold;
945 const std::size_t unfold_deb = learning_fold * foldSize;
946 const std::size_t unfold_end = unfold_deb + foldSize;
947
948 ranges_.clear();
949 if (learning_fold == std::size_t(0)) {
950 ranges_.push_back(std::pair< std::size_t, std::size_t >(unfold_end, db_size));
951 } else {
952 ranges_.push_back(std::pair< std::size_t, std::size_t >(std::size_t(0), unfold_deb));
953
954 if (learning_fold != k_fold - 1) {
955 ranges_.push_back(std::pair< std::size_t, std::size_t >(unfold_end, db_size));
956 }
957 }
958
959 return std::pair< std::size_t, std::size_t >(unfold_deb, unfold_end);
960 }

References GUM_ERROR, ranges_, and scoreDatabase_.

◆ 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 1131 of file IBNLearner.cpp.

1132 {
1133 // use a score to detect whether the ranges are ok
1134 ScoreLog2Likelihood score(scoreDatabase_.parser(), *noPrior_);
1135 score.setRanges(new_ranges);
1136 ranges_ = score.ranges();
1137 }

References noPrior_, ranges_, score(), and scoreDatabase_.

Here is the call graph for this function:

◆ useDirichletPrior() [1/2]

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useDirichletPrior ( const gum::BayesNet< GUM_SCALAR > & bn,
double weight = 1 )
inline

Definition at line 485 of file BNLearner.h.

486 {
487 if (weight < 0) { GUM_ERROR(OutOfBounds, "the weight of the prior must be positive") }
488
492
494 return *this;
495 }
BayesNet< GUM_SCALAR > _prior_bn_
Definition BNLearner.h:713
void _setPriorWeight_(double weight)
sets the prior weight

References BNLearner(), _prior_bn_, gum::learning::IBNLearner::_setPriorWeight_(), gum::learning::IBNLearner::checkScorePriorCompatibility(), gum::learning::IBNLearner::DIRICHLET_FROM_BAYESNET, GUM_ERROR, and gum::learning::IBNLearner::priorType_.

Here is the call graph for this function:

◆ useDirichletPrior() [2/2]

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useDirichletPrior ( const std::string & filename,
double weight = 1 )
inline

Definition at line 480 of file BNLearner.h.

480 {
482 return *this;
483 }
void useDirichletPrior(const std::string &filename, double weight=1)
use the Dirichlet prior from a database

References BNLearner(), and gum::learning::IBNLearner::useDirichletPrior().

Here is the call graph for this function:

◆ useEM()

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useEM ( const double epsilon,
const double noise = default_EM_noise )
inline

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].

Definition at line 261 of file BNLearner.h.

261 {
263 return *this;
264 }
void useEM(const double epsilon, const double noise=default_EM_noise)
use The EM algorithm to learn parameters

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

Here is the call graph for this function:

◆ useEMWithDiffCriterion()

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useEMWithDiffCriterion ( const double epsilon,
const double noise = default_EM_noise )
inline

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].

Definition at line 303 of file BNLearner.h.

304 {
306 return *this;
307 }
void useEMWithDiffCriterion(const double epsilon, const double noise=default_EM_noise)
use The EM algorithm to learn parameters with the diff stopping criterion

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

Here is the call graph for this function:

◆ useEMWithRateCriterion()

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useEMWithRateCriterion ( const double epsilon,
const double noise = default_EM_noise )
inline

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].

Definition at line 283 of file BNLearner.h.

284 {
286 return *this;
287 }
void useEMWithRateCriterion(const double epsilon, const double noise=default_EM_noise)
use The EM algorithm to learn parameters with the rate stopping criterion

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

Here is the call graph for this function:

◆ useGreedyHillClimbing()

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

Definition at line 497 of file BNLearner.h.

497 {
499 return *this;
500 }
void useGreedyHillClimbing()
indicate that we wish to use a greedy hill climbing algorithm

References BNLearner(), and gum::learning::IBNLearner::useGreedyHillClimbing().

Here is the call graph for this function:

◆ useK2() [1/2]

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

Definition at line 508 of file BNLearner.h.

508 {
510 return *this;
511 }
void useK2(const Sequence< NodeId > &order)
indicate that we wish to use K2

References BNLearner(), and gum::learning::IBNLearner::useK2().

Here is the call graph for this function:

◆ useK2() [2/2]

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

Definition at line 513 of file BNLearner.h.

513 {
515 return *this;
516 }

References BNLearner(), and gum::learning::IBNLearner::useK2().

Here is the call graph for this function:

◆ useLocalSearchWithTabuList()

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useLocalSearchWithTabuList ( Size tabu_size = 100,
Size nb_decrease = 2 )
inline

Definition at line 502 of file BNLearner.h.

503 {
505 return *this;
506 }
void useLocalSearchWithTabuList(Size tabu_size=100, Size nb_decrease=2)
indicate that we wish to use a local search with tabu list

References BNLearner(), and gum::learning::IBNLearner::useLocalSearchWithTabuList().

Here is the call graph for this function:

◆ useMDLCorrection()

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

Definition at line 528 of file BNLearner.h.

528 {
530 return *this;
531 }
void useMDLCorrection()
indicate that we wish to use the MDL correction for MIIC

References BNLearner(), and gum::learning::IBNLearner::useMDLCorrection().

Here is the call graph for this function:

◆ useMIIC()

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

Definition at line 518 of file BNLearner.h.

518 {
520 return *this;
521 }
void useMIIC()
indicate that we wish to use MIIC

References BNLearner(), and gum::learning::IBNLearner::useMIIC().

Here is the call graph for this function:

◆ useNMLCorrection()

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

Definition at line 523 of file BNLearner.h.

523 {
525 return *this;
526 }
void useNMLCorrection()
indicate that we wish to use the NML correction for and MIIC

References BNLearner(), and gum::learning::IBNLearner::useNMLCorrection().

Here is the call graph for this function:

◆ useNoCorrection()

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

Definition at line 533 of file BNLearner.h.

533 {
535 return *this;
536 }
void useNoCorrection()
indicate that we wish to use the NoCorr correction for MIIC

References BNLearner(), and gum::learning::IBNLearner::useNoCorrection().

Here is the call graph for this function:

◆ useNoPrior()

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

Definition at line 465 of file BNLearner.h.

465 {
467 return *this;
468 }
void useNoPrior()
use no prior

References BNLearner(), and gum::learning::IBNLearner::useNoPrior().

Here is the call graph for this function:

◆ useScoreAIC()

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

Definition at line 435 of file BNLearner.h.

435 {
437 return *this;
438 }
void useScoreAIC()
indicate that we wish to use an AIC score

References BNLearner(), and gum::learning::IBNLearner::useScoreAIC().

Here is the call graph for this function:

◆ useScoreBD()

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

Definition at line 440 of file BNLearner.h.

440 {
442 return *this;
443 }
void useScoreBD()
indicate that we wish to use a BD score

References BNLearner(), and gum::learning::IBNLearner::useScoreBD().

Here is the call graph for this function:

◆ useScoreBDeu()

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

Definition at line 445 of file BNLearner.h.

445 {
447 return *this;
448 }
void useScoreBDeu()
indicate that we wish to use a BDeu score

References BNLearner(), and gum::learning::IBNLearner::useScoreBDeu().

Here is the call graph for this function:

◆ useScoreBIC()

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

Definition at line 450 of file BNLearner.h.

450 {
452 return *this;
453 }
void useScoreBIC()
indicate that we wish to use a BIC score

References BNLearner(), and gum::learning::IBNLearner::useScoreBIC().

Here is the call graph for this function:

◆ useScoreK2()

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

Definition at line 455 of file BNLearner.h.

455 {
457 return *this;
458 }
void useScoreK2()
indicate that we wish to use a K2 score

References BNLearner(), and gum::learning::IBNLearner::useScoreK2().

Here is the call graph for this function:

◆ useScoreLog2Likelihood()

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

Definition at line 460 of file BNLearner.h.

460 {
462 return *this;
463 }
void useScoreLog2Likelihood()
indicate that we wish to use a Log2Likelihood score

References BNLearner(), and gum::learning::IBNLearner::useScoreLog2Likelihood().

Here is the call graph for this function:

◆ useSmoothingPrior()

template<typename GUM_SCALAR>
BNLearner< GUM_SCALAR > & gum::learning::BNLearner< GUM_SCALAR >::useSmoothingPrior ( double weight = 1)
inline

Definition at line 475 of file BNLearner.h.

475 {
477 return *this;
478 }
void useSmoothingPrior(double weight=1)
use the prior smoothing

References BNLearner(), and gum::learning::IBNLearner::useSmoothingPrior().

Here is the call graph for this function:

◆ verbosity()

bool gum::learning::IBNLearner::verbosity ( ) const
inlineoverridevirtualinherited

verbosity

Implements gum::IApproximationSchemeConfiguration.

Definition at line 1294 of file IBNLearner.h.

1294 {
1295 if (currentAlgorithm_ != nullptr) return currentAlgorithm_->verbosity();
1296 else GUM_ERROR(FatalError, "No chosen algorithm for learning")
1297 }

References currentAlgorithm_, and GUM_ERROR.

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.

126{0};

◆ _prior_bn_

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

Definition at line 713 of file BNLearner.h.

Referenced by useDirichletPrior().

◆ algoK2_

◆ algoMiic_

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

the Constraint MIIC algorithm

Definition at line 1001 of file IBNLearner.h.

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

◆ algoSimpleMiic_

SimpleMiic gum::learning::IBNLearner::algoSimpleMiic_
protectedinherited

the MIIC algorithm

Definition at line 998 of file IBNLearner.h.

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

◆ constraintForbiddenArcs_

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

the constraint on forbidden arcs

Definition at line 976 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), addForbiddenArc(), eraseForbiddenArc(), learnDag_(), operator=(), operator=(), prepareMiic_(), and setForbiddenArcs().

◆ constraintIndegree_

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

the constraint for indegrees

Definition at line 970 of file IBNLearner.h.

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

◆ constraintMandatoryArcs_

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

the constraint on mandatory arcs

Definition at line 982 of file IBNLearner.h.

Referenced by IBNLearner(), IBNLearner(), addMandatoryArc(), eraseMandatoryArc(), learnDag_(), operator=(), operator=(), prepareMiic_(), and setMandatoryArcs().

◆ constraintNoChildrenNodes_

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

the constraint on no children nodes

Definition at line 988 of file IBNLearner.h.

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

◆ constraintNoParentNodes_

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

the constraint on no parent nodes

Definition at line 985 of file IBNLearner.h.

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

◆ constraintPossibleEdges_

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

the constraint on possible Edges

Definition at line 979 of file IBNLearner.h.

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

◆ constraintSliceOrder_

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

the constraint for 2TBNs

Definition at line 967 of file IBNLearner.h.

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

◆ constraintTabuList_

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

the constraint for tabu lists

Definition at line 973 of file IBNLearner.h.

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

◆ currentAlgorithm_

◆ dag2BN_

◆ default_EM_noise

double gum::learning::IBNLearner::default_EM_noise {0.1}
staticconstexprinherited

the default noise amount added to CPTs during EM's initialization (see method useEM())

Definition at line 120 of file IBNLearner.h.

120{0.1};

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

◆ filename_

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

the filename database

Definition at line 1032 of file IBNLearner.h.

1032{"-"};

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

◆ greedyHillClimbing_

◆ inducedTypes_

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

the policy for typing variables

Definition at line 935 of file IBNLearner.h.

935{false};

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

◆ initialDag_

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

an initial DAG given to learners

Definition at line 1029 of file IBNLearner.h.

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

◆ kmodeMiic_

◆ localSearchWithTabuList_

◆ mutualInfo_

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

the selected correction for miic

Definition at line 953 of file IBNLearner.h.

953{nullptr};

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

◆ nbDecreasingChanges_

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

Definition at line 1035 of file IBNLearner.h.

1035{2};

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

◆ noiseEM_

double gum::learning::IBNLearner::noiseEM_ {0.1}
protectedinherited

the noise factor (in (0,1)) used by EM for perturbing the CPT during init

Definition at line 950 of file IBNLearner.h.

950{0.1};

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

◆ noPrior_

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

◆ onProgress

◆ onStop

Signaler1< const std::string& > gum::IApproximationSchemeConfiguration::onStop
inherited

Criteria messageApproximationScheme.

Definition at line 83 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 944 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 1023 of file IBNLearner.h.

1023{nullptr};

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 1026 of file IBNLearner.h.

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

◆ priorType_

◆ priorWeight_

double gum::learning::IBNLearner::priorWeight_ {1.0f}
protectedinherited

the weight of the prior

Definition at line 964 of file IBNLearner.h.

964{1.0f};

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

the score used

Definition at line 941 of file IBNLearner.h.

941{nullptr};

Referenced by ~IBNLearner(), createParamEstimator_(), createScore_(), learnDag_(), operator=(), operator=(), score(), and setNumberOfThreads().

◆ scoreDatabase_

◆ scoreType_

ScoreType gum::learning::IBNLearner::scoreType_ {ScoreType::BDeu}
protectedinherited

◆ selectedAlgo_

AlgoType gum::learning::IBNLearner::selectedAlgo_ {AlgoType::MIIC}
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 947 of file IBNLearner.h.

947{false};

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: