![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
The Miic learning algorithm. More...
#include <Miic.h>
Public Types | |
| enum class | ApproximationSchemeSTATE : char { Undefined , Continue , Epsilon , Rate , Limit , TimeLimit , Stopped } |
| The different state of an approximation scheme. More... | |
Public Member Functions | |
| Miic & | operator= (const Miic &from) |
| copy operator | |
| Miic & | operator= (Miic &&from) |
| move operator | |
| void | setForbiddenGraph (gum::DiGraph forbidGraph) |
| Set ForbiddenGraph (resp. MadatoryGraph) which contains the forbidden (resp. mandatory) arcs. | |
| void | setMandatoryGraph (gum::DAG mandaGraph) |
| void | setMaxIndegree (gum::Size n) |
Constructors / Destructors | |
| Miic () | |
| default constructor | |
| Miic (int maxLog) | |
| default constructor with maxLog | |
| Miic (const Miic &from) | |
| copy constructor | |
| Miic (Miic &&from) | |
| move constructor | |
| ~Miic () override | |
| destructor | |
Accessors / Modifiers | |
| MixedGraph | learnSkeleton (CorrectedMutualInformation &mutualInformation, MixedGraph graph) |
| learns the skeleton of a MixedGraph (no orientation). | |
| MixedGraph | learnMixedStructure (CorrectedMutualInformation &mutualInformation, MixedGraph graph) |
| learns the structure of a MixedGraph (Meek rules not used here). | |
| PDAG | learnPDAG (CorrectedMutualInformation &mutualInformation, MixedGraph graph) |
| learns the structure of an Essential Graph | |
| DAG | learnStructure (CorrectedMutualInformation &I, MixedGraph graph) |
| learns the structure of a Bayesian network, i.e. a DAG, by first learning an Essential graph and then directing the remaining edges. | |
| template<typename GUM_SCALAR = double, typename GRAPH_CHANGES_SELECTOR, typename PARAM_ESTIMATOR> | |
| BayesNet< GUM_SCALAR > | learnBN (GRAPH_CHANGES_SELECTOR &selector, PARAM_ESTIMATOR &estimator, DAG initial_dag=DAG()) |
| learns the structure and the parameters of a BN | |
| const std::vector< Arc > | latentVariables () const |
| get the list of arcs hiding latent variables | |
| void | addConstraints (HashTable< std::pair< NodeId, NodeId >, char > constraints) |
| Set a ensemble of constraints for the orientation phase. | |
Getters and setters | |
| void | setEpsilon (double eps) override |
| Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)|. | |
| double | epsilon () const override |
| Returns the value of epsilon. | |
| void | disableEpsilon () override |
| Disable stopping criterion on epsilon. | |
| void | enableEpsilon () override |
| Enable stopping criterion on epsilon. | |
| bool | isEnabledEpsilon () const override |
| Returns true if stopping criterion on epsilon is enabled, false otherwise. | |
| void | setMinEpsilonRate (double rate) override |
| Given that we approximate f(t), stopping criterion on d/dt(|f(t+1)-f(t)|). | |
| double | minEpsilonRate () const override |
| Returns 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 |
| Returns true if stopping criterion on epsilon rate is enabled, false otherwise. | |
| void | setMaxIter (Size max) override |
| Stopping criterion on number of iterations. | |
| Size | maxIter () const override |
| Returns the criterion on number of iterations. | |
| void | disableMaxIter () override |
| Disable stopping criterion on max iterations. | |
| void | enableMaxIter () override |
| Enable stopping criterion on max iterations. | |
| bool | isEnabledMaxIter () const override |
| Returns true if stopping criterion on max iterations is enabled, false otherwise. | |
| void | setMaxTime (double timeout) override |
| Stopping criterion on timeout. | |
| double | maxTime () const override |
| Returns the timeout (in seconds). | |
| double | currentTime () const override |
| Returns the current running time in second. | |
| void | disableMaxTime () override |
| Disable stopping criterion on timeout. | |
| void | enableMaxTime () override |
| Enable stopping criterion on timeout. | |
| bool | isEnabledMaxTime () const override |
| Returns true if stopping criterion on timeout is enabled, false otherwise. | |
| void | setPeriodSize (Size p) override |
| How many samples between two stopping is enable. | |
| Size | periodSize () const override |
| Returns the period size. | |
| void | setVerbosity (bool v) override |
| Set the verbosity on (true) or off (false). | |
| bool | verbosity () const override |
| Returns true if verbosity is enabled. | |
| ApproximationSchemeSTATE | stateApproximationScheme () const override |
| Returns the approximation scheme state. | |
| Size | nbrIterations () const override |
| Returns the number of iterations. | |
| const std::vector< double > & | history () const override |
| Returns the scheme history. | |
| void | initApproximationScheme () |
| Initialise the scheme. | |
| bool | startOfPeriod () const |
| Returns true if we are at the beginning of a period (compute error is mandatory). | |
| void | updateApproximationScheme (unsigned int incr=1) |
| Update the scheme w.r.t the new error and increment steps. | |
| Size | remainingBurnIn () const |
| Returns the remaining burn in. | |
| void | stopApproximationScheme () |
| Stop the approximation scheme. | |
| bool | continueApproximationScheme (double error) |
| Update the scheme w.r.t the new error. | |
Getters and setters | |
| std::string | messageApproximationScheme () const |
| Returns the approximation scheme message. | |
Public Attributes | |
| Signaler4< gum::NodeId, gum::NodeId, std::string, std::string > | onStructuralModification |
| Signaler3< Size, double, double > | onProgress |
| Progression, error and time. | |
| Signaler1< const std::string & > | onStop |
| Criteria messageApproximationScheme. | |
Protected Member Functions | |
| void | findBestContributor_ (NodeId x, NodeId y, const std::vector< NodeId > &ui, const MixedGraph &graph, CorrectedMutualInformation &mutualInformation, Heap< CondRanking, GreaterPairOn2nd > &rank) |
| finds the best contributor node for a pair given a conditioning set | |
| std::vector< Ranking > | unshieldedTriples_ (const MixedGraph &graph, CorrectedMutualInformation &mutualInformation, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet) |
| gets the list of unshielded triples in the graph in decreasing value of |I'(x, y, z|{ui})| | |
| std::vector< ProbabilisticRanking > | unshieldedTriplesMiic_ (const MixedGraph &graph, CorrectedMutualInformation &mutualInformation, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, HashTable< std::pair< NodeId, NodeId >, char > &marks) |
| gets the list of unshielded triples in the graph in decreasing value of |I'(x, y, z|{ui})|, prepares the orientation matrix for MIIC | |
| std::vector< ProbabilisticRanking > | updateProbaTriples_ (const MixedGraph &graph, std::vector< ProbabilisticRanking > probaTriples) |
| Gets the orientation probabilities like MIIC for the orientation phase. | |
| void | orientDoubleHeadedArcs_ (MixedGraph &mg) |
| Orient double headed arcs to avoid cycles. | |
| bool | isForbiddenArc_ (NodeId x, NodeId y) const |
| Check constraints. | |
| bool | isForbiddenEdge_ (NodeId x, NodeId y) |
| bool | isMaxIndegree_ (MixedGraph graph, NodeId x) |
| bool | isArcValid_ (MixedGraph graph, NodeId x, NodeId y) |
Main phases | |
Set a ensemble of constraints for the learning/orientation phase | |
| void | initiation_ (CorrectedMutualInformation &mutualInformation, MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, Heap< CondRanking, GreaterPairOn2nd > &rank) |
| Initiation phase. | |
| void | iteration_ (CorrectedMutualInformation &mutualInformation, MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, Heap< CondRanking, GreaterPairOn2nd > &rank) |
| Iteration phase. | |
| void | orientationMiic_ (CorrectedMutualInformation &mutualInformation, MixedGraph &graph, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet) |
| Orientation phase from the MIIC algorithm, returns a mixed graph that may contain circles. | |
Protected Attributes | |
| gum::MeekRules | meekRules_ |
| Object that can propagates orientations to non-oriented edges. | |
| double | current_epsilon_ |
| Current epsilon. | |
| double | last_epsilon_ |
| Last epsilon value. | |
| double | current_rate_ |
| Current rate. | |
| Size | current_step_ |
| The current step. | |
| Timer | timer_ |
| The timer. | |
| ApproximationSchemeSTATE | current_state_ |
| The current state. | |
| std::vector< double > | history_ |
| The scheme history, used only if verbosity == true. | |
| double | eps_ |
| Threshold for convergence. | |
| bool | enabled_eps_ |
| If true, the threshold convergence is enabled. | |
| double | min_rate_eps_ |
| Threshold for the epsilon rate. | |
| bool | enabled_min_rate_eps_ |
| If true, the minimal threshold for epsilon rate is enabled. | |
| double | max_time_ |
| The timeout. | |
| bool | enabled_max_time_ |
| If true, the timeout is enabled. | |
| Size | max_iter_ |
| The maximum iterations. | |
| bool | enabled_max_iter_ |
| If true, the maximum iterations stopping criterion is enabled. | |
| Size | burn_in_ |
| Number of iterations before checking stopping criteria. | |
| Size | period_size_ |
| Checking criteria frequency. | |
| bool | verbosity_ |
| If true, verbosity is enabled. | |
Private Member Functions | |
| void | _orientingVstructureMiic_ (MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, char > &marks, NodeId x, NodeId y, NodeId z, double p1, double p2) |
| void | _propagatingOrientationMiic_ (MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, char > &marks, NodeId x, NodeId y, NodeId z, double p1, double p2) |
| bool | _isNotLatentCouple_ (NodeId x, NodeId y) |
| void | stopScheme_ (ApproximationSchemeSTATE new_state) |
| Stop the scheme given a new state. | |
Static Private Member Functions | |
| static bool | _existsNonTrivialDirectedPath_ (const MixedGraph &graph, NodeId n1, NodeId n2) |
| checks for directed paths in a graph, considering double arcs like edges, not considering arc as a directed path. | |
| static bool | _existsDirectedPath_ (const MixedGraph &graph, NodeId n1, NodeId n2) |
| checks for directed paths in a graph, consider double arcs like edges | |
Private Attributes | |
| int | _maxLog_ = 100 |
| Fixes the maximum log that we accept in exponential computations. | |
| const std::vector< NodeId > | _emptySet_ |
| an empty conditioning set | |
| std::vector< Arc > | _latentCouples_ |
| an empty vector of arcs | |
| gum::Size | _maxIndegree_ |
| maximum number of parents | |
| Size | _size_ |
| size of the database | |
| ArcProperty< double > | _arcProbas_ |
| Storing the propabilities for each arc set in the graph. | |
| HashTable< std::pair< NodeId, NodeId >, char > | _initialMarks_ |
| Initial marks for the orientation phase, used to convey constraints. | |
| gum::DAG | _mandatoryGraph_ |
| Graph that contains the mandatories arcs. | |
| gum::DiGraph | _forbiddenGraph_ |
| Graph that contains the forbidden arcs. | |
The Miic learning algorithm.
The Miic class implements the miic algorithm based on https://doi.org/10.1371/journal.pcbi.1005662. It starts by eliminating edges that correspond to independent variables to build the skeleton of the graph, and then directs the remaining edges to get an essential graph. Latent variables can be detected using bi-directed arcs.
Miic allows the option of adding constraints on the skeleton construction such as: a maximum number of parents, mandatory arcs, forbidden arcs or an order between the variables.
|
stronginherited |
The different state of an approximation scheme.
| Enumerator | |
|---|---|
| Undefined | |
| Continue | |
| Epsilon | |
| Rate | |
| Limit | |
| TimeLimit | |
| Stopped | |
Definition at line 86 of file IApproximationSchemeConfiguration.h.
| gum::learning::Miic::Miic | ( | ) |
default constructor
Definition at line 63 of file Miic.cpp.
References Miic(), _maxLog_, and _size_.
Referenced by Miic(), Miic(), Miic(), Miic(), ~Miic(), operator=(), and operator=().
|
explicit |
| gum::learning::Miic::Miic | ( | const Miic & | from | ) |
copy constructor
Definition at line 69 of file Miic.cpp.
References gum::ApproximationScheme::ApproximationScheme(), Miic(), and _size_.
| gum::learning::Miic::Miic | ( | Miic && | from | ) |
move constructor
Definition at line 74 of file Miic.cpp.
References gum::ApproximationScheme::ApproximationScheme(), Miic(), and _size_.
|
override |
|
staticprivate |
checks for directed paths in a graph, consider double arcs like edges
| graph | MixedGraph in which to search the path |
| n1 | tail of the path |
| n2 | head of the path |
Definition at line 930 of file Miic.cpp.
References gum::List< Val >::empty(), gum::Set< Key >::exists(), gum::ArcGraphPart::existsArc(), gum::List< Val >::front(), gum::Set< Key >::insert(), gum::ArcGraphPart::parents(), gum::List< Val >::popFront(), and gum::List< Val >::pushBack().
Referenced by _existsNonTrivialDirectedPath_(), _propagatingOrientationMiic_(), orientationMiic_(), and orientDoubleHeadedArcs_().
|
staticprivate |
checks for directed paths in a graph, considering double arcs like edges, not considering arc as a directed path.
| graph | MixedGraph in which to search the path |
| n1 | tail of the path |
| n2 | head of the path |
| countArc | bool to know if we |
Definition at line 917 of file Miic.cpp.
References _existsDirectedPath_(), gum::ArcGraphPart::existsArc(), and gum::ArcGraphPart::parents().
Referenced by _orientingVstructureMiic_().
Definition at line 964 of file Miic.cpp.
References _latentCouples_.
Referenced by _orientingVstructureMiic_().
|
private |
Definition at line 420 of file Miic.cpp.
References _arcProbas_, _existsNonTrivialDirectedPath_(), _isNotLatentCouple_(), _latentCouples_, gum::DiGraph::addArc(), gum::EdgeGraphPart::eraseEdge(), gum::ArcGraphPart::existsArc(), GUM_SL_EMIT, and isArcValid_().
Referenced by orientationMiic_().
|
private |
Definition at line 548 of file Miic.cpp.
References _arcProbas_, _existsDirectedPath_(), _latentCouples_, gum::DiGraph::addArc(), gum::Set< Key >::empty(), gum::EdgeGraphPart::eraseEdge(), GUM_SL_EMIT, isArcValid_(), and gum::ArcGraphPart::parents().
Referenced by orientationMiic_().
| void gum::learning::Miic::addConstraints | ( | HashTable< std::pair< NodeId, NodeId >, char > | constraints | ) |
Set a ensemble of constraints for the orientation phase.
Definition at line 913 of file Miic.cpp.
References _initialMarks_.
Update the scheme w.r.t the new error.
Test the stopping criterion that are enabled.
| error | The new error value. |
| OperationNotAllowed | Raised if state != ApproximationSchemeSTATE::Continue. |
Definition at line 229 of file approximationScheme_inl.h.
References enabled_max_time_, and timer_.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), gum::SamplingInference< GUM_SCALAR >::loopApproxInference_(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceByOrderedArcs_(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceByRandomOrder_(), and gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceNodeToNeighbours_().
|
overridevirtualinherited |
Returns the current running time in second.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 136 of file approximationScheme_inl.h.
References timer_.
|
overridevirtualinherited |
Disable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 74 of file approximationScheme_inl.h.
References enabled_eps_.
Referenced by gum::learning::EMApproximationScheme::EMApproximationScheme(), and gum::learning::EMApproximationScheme::setMinEpsilonRate().
|
overridevirtualinherited |
Disable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 115 of file approximationScheme_inl.h.
References enabled_max_iter_.
Referenced by gum::learning::GreedyHillClimbing::GreedyHillClimbing().
|
overridevirtualinherited |
Disable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 139 of file approximationScheme_inl.h.
References enabled_max_time_.
Referenced by gum::learning::GreedyHillClimbing::GreedyHillClimbing().
|
overridevirtualinherited |
Disable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 95 of file approximationScheme_inl.h.
References enabled_min_rate_eps_.
Referenced by gum::learning::GreedyHillClimbing::GreedyHillClimbing(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and gum::learning::EMApproximationScheme::setEpsilon().
|
overridevirtualinherited |
Enable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 77 of file approximationScheme_inl.h.
References enabled_eps_.
|
overridevirtualinherited |
Enable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 118 of file approximationScheme_inl.h.
References enabled_max_iter_.
|
overridevirtualinherited |
Enable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 142 of file approximationScheme_inl.h.
References enabled_max_time_.
|
overridevirtualinherited |
Enable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 98 of file approximationScheme_inl.h.
References enabled_min_rate_eps_.
Referenced by gum::learning::EMApproximationScheme::EMApproximationScheme(), and gum::GibbsBNdistance< GUM_SCALAR >::computeKL_().
|
overridevirtualinherited |
Returns the value of epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 71 of file approximationScheme_inl.h.
References eps_.
Referenced by gum::ImportanceSampling< GUM_SCALAR >::onContextualize_(), and gum::ImportanceSampling< GUM_SCALAR >::unsharpenBN_().
|
protected |
finds the best contributor node for a pair given a conditioning set
| x | first node |
| y | second node |
| ui | conditioning set |
| mutualInformation | A mutual information instance that will do the computations and has loaded the database. |
| graph | containing the assessed nodes |
| rank | the heap of ranks of the algorithm |
Definition at line 718 of file Miic.cpp.
References _maxLog_, gum::Heap< Val, Cmp >::insert(), M_LN2, and gum::learning::CorrectedMutualInformation::score().
Referenced by initiation_(), and iteration_().
|
overridevirtualinherited |
Returns the scheme history.
| OperationNotAllowed | Raised if the scheme did not performed or if verbosity is set to false. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 178 of file approximationScheme_inl.h.
References GUM_ERROR, stateApproximationScheme(), and gum::IApproximationSchemeConfiguration::Undefined.
|
inherited |
Initialise the scheme.
Definition at line 189 of file approximationScheme_inl.h.
References ApproximationScheme(), gum::IApproximationSchemeConfiguration::Continue, current_epsilon_, current_rate_, current_state_, current_step_, and initApproximationScheme().
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), initApproximationScheme(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), gum::SamplingInference< GUM_SCALAR >::loopApproxInference_(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInference(), and gum::SamplingInference< GUM_SCALAR >::onStateChanged_().
|
protected |
Initiation phase.
We go over all edges and test if the variables are marginally independent. If they are, the edge is deleted. If not, the best contributor is found.
| mutualInformation | A mutual information instance that will do the computations and has loaded the database. |
| graph | the MixedGraph we start from for the learning |
| sepSet | the separation set for independent couples, here set to {} |
| rank | the heap of ranks of the algorithm |
Definition at line 204 of file Miic.cpp.
References _emptySet_, gum::ApproximationScheme::current_step_, gum::EdgeGraphPart::edges(), gum::EdgeGraphPart::eraseEdge(), findBestContributor_(), GUM_EMIT3, GUM_SL_EMIT, isForbiddenEdge_(), gum::IApproximationSchemeConfiguration::onProgress, gum::learning::CorrectedMutualInformation::score(), gum::Set< Key >::size(), and gum::ApproximationScheme::timer_.
Referenced by learnMixedStructure(), and learnSkeleton().
|
protected |
Definition at line 988 of file Miic.cpp.
References isForbiddenArc_(), and isMaxIndegree_().
Referenced by _orientingVstructureMiic_(), and _propagatingOrientationMiic_().
|
overridevirtualinherited |
Returns true if stopping criterion on epsilon is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 81 of file approximationScheme_inl.h.
References enabled_eps_.
|
overridevirtualinherited |
Returns true if stopping criterion on max iterations is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 122 of file approximationScheme_inl.h.
References enabled_max_iter_.
|
overridevirtualinherited |
Returns true if stopping criterion on timeout is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 146 of file approximationScheme_inl.h.
References enabled_max_time_.
|
overridevirtualinherited |
Returns true if stopping criterion on epsilon rate is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 102 of file approximationScheme_inl.h.
References enabled_min_rate_eps_.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_().
Check constraints.
Definition at line 984 of file Miic.cpp.
References _forbiddenGraph_.
Referenced by isArcValid_().
Definition at line 992 of file Miic.cpp.
References _forbiddenGraph_.
Referenced by initiation_().
|
protected |
Definition at line 980 of file Miic.cpp.
References _maxIndegree_, gum::ArcGraphPart::parents(), and gum::Set< Key >::size().
Referenced by isArcValid_().
|
protected |
Iteration phase.
As long as we find important nodes for edges, we go over them to see if we can assess the conditional independence of the variables.
| mutualInformation | A mutual information instance that will do the computations and has loaded the database. |
| graph | the MixedGraph returned from the previous phase |
| sepSet | the separation set for independent couples, built during the iterations of the phase |
| rank | the heap of ranks of the algorithm |
Definition at line 253 of file Miic.cpp.
References gum::ApproximationScheme::current_step_, gum::EdgeGraphPart::eraseEdge(), findBestContributor_(), GUM_EMIT3, GUM_SL_EMIT, gum::IApproximationSchemeConfiguration::onProgress, gum::Heap< Val, Cmp >::pop(), gum::learning::CorrectedMutualInformation::score(), gum::Heap< Val, Cmp >::size(), gum::ApproximationScheme::timer_, and gum::Heap< Val, Cmp >::top().
Referenced by learnMixedStructure(), and learnSkeleton().
| const std::vector< Arc > gum::learning::Miic::latentVariables | ( | ) | const |
get the list of arcs hiding latent variables
Definition at line 911 of file Miic.cpp.
References _latentCouples_.
| BayesNet< GUM_SCALAR > gum::learning::Miic::learnBN | ( | GRAPH_CHANGES_SELECTOR & | selector, |
| PARAM_ESTIMATOR & | estimator, | ||
| DAG | initial_dag = DAG() ) |
learns the structure and the parameters of a BN
| selector | A selector class that computes the best changes that can be applied and that enables the user to get them very easily. Typically, the selector is a GraphChangesSelector4DiGraph<SCORE, STRUCT_CONSTRAINT, GRAPH_CHANGES_GENERATOR>. |
| estimator | A estimator. |
| names | The variables names. |
| modal | the domain sizes of the random variables observed in the database |
| translator | The cell translator to use. |
| initial_dag | the DAG we start from for our learning |
Definition at line 190 of file Miic.cpp.
References gum::learning::DAG2BNLearner::createBN(), and learnStructure().
| MixedGraph gum::learning::Miic::learnMixedStructure | ( | CorrectedMutualInformation & | mutualInformation, |
| MixedGraph | graph ) |
learns the structure of a MixedGraph (Meek rules not used here).
| mutualInformation | A mutual information instance that will do the computations and has loaded the database. |
| graph | the MixedGraph we start from for the learning |
Definition at line 147 of file Miic.cpp.
References _latentCouples_, gum::ApproximationScheme::current_step_, initiation_(), iteration_(), meekRules_, orientationMiic_(), and gum::ApproximationScheme::timer_.
Referenced by learnPDAG(), and learnStructure().
| PDAG gum::learning::Miic::learnPDAG | ( | CorrectedMutualInformation & | mutualInformation, |
| MixedGraph | graph ) |
learns the structure of an Essential Graph
learns the structure of a PDAG from à MixedGraph. It returns a MixedGraph with the constraints of a PDAG, to avoid changing the dependencies in the other methods of the MIIC class.
| mutualInformation | A mutual information instance that will do the computations and has loaded the database. |
| graph | the MixedGraph we start from for the learning |
Definition at line 178 of file Miic.cpp.
References learnMixedStructure(), and meekRules_.
| MixedGraph gum::learning::Miic::learnSkeleton | ( | CorrectedMutualInformation & | mutualInformation, |
| MixedGraph | graph ) |
learns the skeleton of a MixedGraph (no orientation).
learns the skeleton of a Graph from a fully connected graph
| mutualInformation | A mutual information instance that will do the computations and has loaded the database. |
| graph | the MixedGraph we start from for the learning |
Definition at line 124 of file Miic.cpp.
References _latentCouples_, gum::ApproximationScheme::current_step_, initiation_(), iteration_(), and gum::ApproximationScheme::timer_.
| DAG gum::learning::Miic::learnStructure | ( | CorrectedMutualInformation & | I, |
| MixedGraph | graph ) |
learns the structure of a Bayesian network, i.e. a DAG, by first learning an Essential graph and then directing the remaining edges.
| I | A mutual information instance that will do the computations and has loaded the database |
| graph | the MixedGraph we start from for the learning |
Definition at line 183 of file Miic.cpp.
References learnMixedStructure(), and meekRules_.
Referenced by learnBN().
|
overridevirtualinherited |
Returns the criterion on number of iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 112 of file approximationScheme_inl.h.
References max_iter_.
|
overridevirtualinherited |
Returns the timeout (in seconds).
Implements gum::IApproximationSchemeConfiguration.
Definition at line 133 of file approximationScheme_inl.h.
References max_time_.
|
inherited |
Returns the approximation scheme message.
Definition at line 59 of file IApproximationSchemeConfiguration_inl.h.
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().
|
overridevirtualinherited |
Returns the value of the minimal epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 92 of file approximationScheme_inl.h.
References min_rate_eps_.
|
overridevirtualinherited |
Returns the number of iterations.
| OperationNotAllowed | Raised if the scheme did not perform. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 169 of file approximationScheme_inl.h.
References current_step_, GUM_ERROR, stateApproximationScheme(), and gum::IApproximationSchemeConfiguration::Undefined.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_().
|
protected |
Orientation phase from the MIIC algorithm, returns a mixed graph that may contain circles.
The orientation protocol of MIIC.
| mutualInformation | A mutual information instance that will do the computations and has loaded the database. |
| graph | the MixedGraph returned from the previous phase |
| sepSet | the separation set for independent couples, built during the previous phase |
Definition at line 309 of file Miic.cpp.
References _existsDirectedPath_(), _forbiddenGraph_, _initialMarks_, _latentCouples_, _mandatoryGraph_, _orientingVstructureMiic_(), _propagatingOrientationMiic_(), gum::DiGraph::addArc(), gum::ApproximationScheme::current_step_, gum::ArcGraphPart::eraseArc(), gum::EdgeGraphPart::eraseEdge(), gum::EdgeGraphPart::existsEdge(), GUM_EMIT3, GUM_SL_EMIT, gum::HashTable< Key, Val >::insert(), gum::IApproximationSchemeConfiguration::onProgress, gum::ApproximationScheme::timer_, unshieldedTriplesMiic_(), and updateProbaTriples_().
Referenced by learnMixedStructure().
|
protected |
Orient double headed arcs to avoid cycles.
| mg | the MixedGraph from which the double headed arcs will be oriented. |
Definition at line 653 of file Miic.cpp.
References _existsDirectedPath_(), gum::Set< Key >::begin(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), gum::ArcGraphPart::eraseArc(), gum::Set< Key >::insert(), gum::NodeGraphPart::nodes(), and gum::ArcGraphPart::parents().
|
overridevirtualinherited |
Returns the period size.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 155 of file approximationScheme_inl.h.
References period_size_.
|
inherited |
Returns the remaining burn in.
Definition at line 212 of file approximationScheme_inl.h.
References burn_in_, and current_step_.
|
overridevirtualinherited |
Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)|.
If the criterion was disabled it will be enabled.
| eps | The new epsilon value. |
| OutOfBounds | Raised if eps < 0. |
Implements gum::IApproximationSchemeConfiguration.
Reimplemented in gum::learning::EMApproximationScheme.
Definition at line 63 of file approximationScheme_inl.h.
References enabled_eps_, eps_, and GUM_ERROR.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsSampling< GUM_SCALAR >::GibbsSampling(), gum::learning::GreedyHillClimbing::GreedyHillClimbing(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::EMApproximationScheme::setEpsilon().
| void gum::learning::Miic::setForbiddenGraph | ( | gum::DiGraph | forbidGraph | ) |
Set ForbiddenGraph (resp. MadatoryGraph) which contains the forbidden (resp. mandatory) arcs.
Definition at line 974 of file Miic.cpp.
References _forbiddenGraph_.
| void gum::learning::Miic::setMandatoryGraph | ( | gum::DAG | mandaGraph | ) |
Definition at line 972 of file Miic.cpp.
References _mandatoryGraph_.
| void gum::learning::Miic::setMaxIndegree | ( | gum::Size | n | ) |
|
overridevirtualinherited |
Stopping criterion on number of iterations.
If the criterion was disabled it will be enabled.
| max | The maximum number of iterations. |
| OutOfBounds | Raised if max <= 1. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 105 of file approximationScheme_inl.h.
References enabled_max_iter_, GUM_ERROR, and max_iter_.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), and gum::SamplingInference< GUM_SCALAR >::SamplingInference().
|
overridevirtualinherited |
Stopping criterion on timeout.
If the criterion was disabled it will be enabled.
| timeout | The timeout value in seconds. |
| OutOfBounds | Raised if timeout <= 0.0. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 126 of file approximationScheme_inl.h.
References enabled_max_time_, GUM_ERROR, and max_time_.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), and gum::SamplingInference< GUM_SCALAR >::SamplingInference().
|
overridevirtualinherited |
Given that we approximate f(t), stopping criterion on d/dt(|f(t+1)-f(t)|).
If the criterion was disabled it will be enabled
| rate | The minimal epsilon rate. |
| OutOfBounds | if rate<0 |
Implements gum::IApproximationSchemeConfiguration.
Reimplemented in gum::learning::EMApproximationScheme.
Definition at line 84 of file approximationScheme_inl.h.
References enabled_min_rate_eps_, GUM_ERROR, and min_rate_eps_.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsSampling< GUM_SCALAR >::GibbsSampling(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::EMApproximationScheme::setMinEpsilonRate().
|
overridevirtualinherited |
How many samples between two stopping is enable.
| p | The new period value. |
| OutOfBounds | Raised if p < 1. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 149 of file approximationScheme_inl.h.
References GUM_ERROR, and period_size_.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), and gum::SamplingInference< GUM_SCALAR >::SamplingInference().
|
overridevirtualinherited |
Set the verbosity on (true) or off (false).
| v | If true, then verbosity is turned on. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 158 of file approximationScheme_inl.h.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), and gum::SamplingInference< GUM_SCALAR >::SamplingInference().
|
inherited |
Returns true if we are at the beginning of a period (compute error is mandatory).
Definition at line 199 of file approximationScheme_inl.h.
References burn_in_, and current_step_.
|
overridevirtualinherited |
Returns the approximation scheme state.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 164 of file approximationScheme_inl.h.
References current_state_.
Referenced by history(), and nbrIterations().
|
inherited |
Stop the approximation scheme.
Definition at line 221 of file approximationScheme_inl.h.
Referenced by gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), and gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceNodeToNeighbours_().
|
privateinherited |
Stop the scheme given a new state.
| new_state | The scheme new state. |
Definition at line 301 of file approximationScheme_inl.h.
References gum::IApproximationSchemeConfiguration::Continue, current_state_, and gum::IApproximationSchemeConfiguration::Undefined.
Referenced by gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::disableMaxIter(), gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::disableMaxTime(), gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::isEnabledMaxIter(), gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::maxTime(), and gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::setPeriodSize().
|
protected |
gets the list of unshielded triples in the graph in decreasing value of |I'(x, y, z|{ui})|
| graph | graph in which to find the triples |
| I | mutual information object to compute the scores |
| sep_set | hashtable storing the separation sets for pairs of variables |
Definition at line 794 of file Miic.cpp.
References gum::EdgeGraphPart::existsEdge(), gum::EdgeGraphPart::neighbours(), and gum::learning::CorrectedMutualInformation::score().
|
protected |
gets the list of unshielded triples in the graph in decreasing value of |I'(x, y, z|{ui})|, prepares the orientation matrix for MIIC
| graph | graph in which to find the triples |
| I | mutual information object to compute the scores |
| sep_set | hashtable storing the separation sets for pairs of variables |
| marks | hashtable containing the orientation marks for edges |
Definition at line 831 of file Miic.cpp.
References gum::EdgeGraphPart::existsEdge(), gum::EdgeGraphPart::neighbours(), gum::learning::CorrectedMutualInformation::score(), and updateProbaTriples_().
Referenced by orientationMiic_().
|
inherited |
Update the scheme w.r.t the new error and increment steps.
| incr | The new increment steps. |
Definition at line 208 of file approximationScheme_inl.h.
References current_step_.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), gum::SamplingInference< GUM_SCALAR >::loopApproxInference_(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceByOrderedArcs_(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceByRandomOrder_(), and gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceNodeToNeighbours_().
|
protected |
Gets the orientation probabilities like MIIC for the orientation phase.
| graph | graph in which to find the triples |
| proba_triples | probabilities for the different triples to update |
Definition at line 872 of file Miic.cpp.
References gum::ArcGraphPart::existsArc().
Referenced by orientationMiic_(), and unshieldedTriplesMiic_().
|
overridevirtualinherited |
Returns true if verbosity is enabled.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 160 of file approximationScheme_inl.h.
References verbosity_.
Referenced by ApproximationScheme(), and gum::learning::EMApproximationScheme::EMApproximationScheme().
|
private |
Storing the propabilities for each arc set in the graph.
Definition at line 355 of file Miic.h.
Referenced by _orientingVstructureMiic_(), and _propagatingOrientationMiic_().
|
private |
|
private |
Graph that contains the forbidden arcs.
Definition at line 364 of file Miic.h.
Referenced by isForbiddenArc_(), isForbiddenEdge_(), orientationMiic_(), and setForbiddenGraph().
Initial marks for the orientation phase, used to convey constraints.
Definition at line 358 of file Miic.h.
Referenced by addConstraints(), and orientationMiic_().
|
private |
an empty vector of arcs
Definition at line 346 of file Miic.h.
Referenced by _isNotLatentCouple_(), _orientingVstructureMiic_(), _propagatingOrientationMiic_(), latentVariables(), learnMixedStructure(), learnSkeleton(), and orientationMiic_().
|
private |
Graph that contains the mandatories arcs.
Definition at line 361 of file Miic.h.
Referenced by orientationMiic_(), and setMandatoryGraph().
|
private |
maximum number of parents
Definition at line 349 of file Miic.h.
Referenced by isMaxIndegree_(), and setMaxIndegree().
|
private |
Fixes the maximum log that we accept in exponential computations.
Definition at line 342 of file Miic.h.
Referenced by Miic(), Miic(), and findBestContributor_().
|
private |
|
protectedinherited |
Number of iterations before checking stopping criteria.
Definition at line 423 of file approximationScheme.h.
Referenced by ApproximationScheme(), gum::GibbsBNdistance< GUM_SCALAR >::burnIn(), gum::GibbsSampling< GUM_SCALAR >::burnIn(), remainingBurnIn(), gum::GibbsBNdistance< GUM_SCALAR >::setBurnIn(), gum::GibbsSampling< GUM_SCALAR >::setBurnIn(), and startOfPeriod().
|
protectedinherited |
Current epsilon.
Definition at line 378 of file approximationScheme.h.
Referenced by initApproximationScheme().
|
protectedinherited |
Current rate.
Definition at line 384 of file approximationScheme.h.
Referenced by initApproximationScheme().
|
protectedinherited |
The current state.
Definition at line 393 of file approximationScheme.h.
Referenced by ApproximationScheme(), initApproximationScheme(), stateApproximationScheme(), and stopScheme_().
|
protectedinherited |
The current step.
Definition at line 387 of file approximationScheme.h.
Referenced by initApproximationScheme(), gum::learning::Miic::initiation_(), gum::learning::SimpleMiic::initiation_(), gum::learning::Miic::iteration_(), gum::learning::SimpleMiic::iteration_(), gum::learning::Miic::learnMixedStructure(), gum::learning::SimpleMiic::learnMixedStructure(), gum::learning::Miic::learnSkeleton(), nbrIterations(), gum::learning::SimpleMiic::orientationLatents_(), gum::learning::Miic::orientationMiic_(), gum::learning::SimpleMiic::orientationMiic_(), remainingBurnIn(), startOfPeriod(), and updateApproximationScheme().
|
protectedinherited |
If true, the threshold convergence is enabled.
Definition at line 402 of file approximationScheme.h.
Referenced by ApproximationScheme(), disableEpsilon(), enableEpsilon(), isEnabledEpsilon(), and setEpsilon().
|
protectedinherited |
If true, the maximum iterations stopping criterion is enabled.
Definition at line 420 of file approximationScheme.h.
Referenced by ApproximationScheme(), disableMaxIter(), enableMaxIter(), isEnabledMaxIter(), and setMaxIter().
|
protectedinherited |
If true, the timeout is enabled.
Definition at line 414 of file approximationScheme.h.
Referenced by ApproximationScheme(), continueApproximationScheme(), disableMaxTime(), enableMaxTime(), isEnabledMaxTime(), and setMaxTime().
|
protectedinherited |
If true, the minimal threshold for epsilon rate is enabled.
Definition at line 408 of file approximationScheme.h.
Referenced by ApproximationScheme(), disableMinEpsilonRate(), enableMinEpsilonRate(), isEnabledMinEpsilonRate(), and setMinEpsilonRate().
|
protectedinherited |
Threshold for convergence.
Definition at line 399 of file approximationScheme.h.
Referenced by ApproximationScheme(), epsilon(), and setEpsilon().
|
protectedinherited |
The scheme history, used only if verbosity == true.
Definition at line 396 of file approximationScheme.h.
|
protectedinherited |
Last epsilon value.
Definition at line 381 of file approximationScheme.h.
|
protectedinherited |
The maximum iterations.
Definition at line 417 of file approximationScheme.h.
Referenced by ApproximationScheme(), maxIter(), and setMaxIter().
|
protectedinherited |
The timeout.
Definition at line 411 of file approximationScheme.h.
Referenced by ApproximationScheme(), maxTime(), and setMaxTime().
|
protected |
Object that can propagates orientations to non-oriented edges.
Definition at line 332 of file Miic.h.
Referenced by learnMixedStructure(), learnPDAG(), and learnStructure().
|
protectedinherited |
Threshold for the epsilon rate.
Definition at line 405 of file approximationScheme.h.
Referenced by ApproximationScheme(), minEpsilonRate(), and setMinEpsilonRate().
Progression, error and time.
Definition at line 80 of file IApproximationSchemeConfiguration.h.
Referenced by gum::learning::IBNLearner::distributeProgress(), gum::learning::Miic::initiation_(), gum::learning::SimpleMiic::initiation_(), gum::learning::Miic::iteration_(), gum::learning::SimpleMiic::iteration_(), gum::learning::SimpleMiic::orientationLatents_(), gum::learning::Miic::orientationMiic_(), and gum::learning::SimpleMiic::orientationMiic_().
|
inherited |
Criteria messageApproximationScheme.
Definition at line 83 of file IApproximationSchemeConfiguration.h.
Referenced by gum::learning::IBNLearner::distributeStop().
| Signaler4< gum::NodeId, gum::NodeId, std::string, std::string > gum::learning::Miic::onStructuralModification |
|
protectedinherited |
Checking criteria frequency.
Definition at line 426 of file approximationScheme.h.
Referenced by ApproximationScheme(), periodSize(), and setPeriodSize().
|
protectedinherited |
The timer.
Definition at line 390 of file approximationScheme.h.
Referenced by continueApproximationScheme(), currentTime(), gum::learning::Miic::initiation_(), gum::learning::SimpleMiic::initiation_(), gum::learning::Miic::iteration_(), gum::learning::SimpleMiic::iteration_(), gum::learning::Miic::learnMixedStructure(), gum::learning::SimpleMiic::learnMixedStructure(), gum::learning::Miic::learnSkeleton(), gum::learning::SimpleMiic::orientationLatents_(), gum::learning::Miic::orientationMiic_(), and gum::learning::SimpleMiic::orientationMiic_().
|
protectedinherited |
If true, verbosity is enabled.
Definition at line 429 of file approximationScheme.h.
Referenced by ApproximationScheme(), and verbosity().