![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
The miic learning algorithm. More...
#include <SimpleMiic.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 | |
| SimpleMiic & | operator= (const SimpleMiic &from) |
| copy operator | |
| SimpleMiic & | operator= (SimpleMiic &&from) |
| move operator | |
Constructors / Destructors | |
| SimpleMiic () | |
| default constructor | |
| SimpleMiic (int maxLog) | |
| default constructor with maxLog | |
| SimpleMiic (const SimpleMiic &from) | |
| copy constructor | |
| SimpleMiic (SimpleMiic &&from) | |
| move constructor | |
| ~SimpleMiic () override | |
| destructor | |
Accessors / Modifiers | |
| MixedGraph | learnPDAG (CorrectedMutualInformation &mutualInformation, MixedGraph graph) |
| learns the structure of an Essential Graph | |
| MixedGraph | learnMixedStructure (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 | |
| Signaler3< Size, double, double > | onProgress |
| Progression, error and time. | |
| Signaler1< const std::string & > | onStop |
| Criteria messageApproximationScheme. | |
Protected Member Functions | |
| void | orientationLatents_ (CorrectedMutualInformation &mutualInformation, MixedGraph &graph, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet) |
| variant trying to propagate both orientations in a bidirected arc | |
| 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. | |
| bool | propagatesRemainingOrientableEdges_ (MixedGraph &graph, NodeId xj) |
| Propagates the orientation from a node to its neighbours. | |
| void | propagatesOrientationInChainOfRemainingEdges_ (MixedGraph &graph) |
| heuristic for remaining edges when everything else has been tried | |
| bool | isForbidenArc_ (NodeId x, NodeId y) const |
| bool | isOrientable_ (const MixedGraph &graph, NodeId xi, NodeId xj) const |
Main phases | |
| 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 | |
| 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 | |
| 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. | |
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.
Definition at line 83 of file SimpleMiic.h.
|
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::SimpleMiic::SimpleMiic | ( | ) |
default constructor
Definition at line 63 of file SimpleMiic.cpp.
References SimpleMiic(), _maxLog_, and _size_.
Referenced by SimpleMiic(), SimpleMiic(), SimpleMiic(), SimpleMiic(), ~SimpleMiic(), operator=(), and operator=().
|
explicit |
default constructor with maxLog
Definition at line 66 of file SimpleMiic.cpp.
References SimpleMiic(), _maxLog_, and _size_.
| gum::learning::SimpleMiic::SimpleMiic | ( | const SimpleMiic & | from | ) |
copy constructor
Definition at line 71 of file SimpleMiic.cpp.
References gum::ApproximationScheme::ApproximationScheme(), SimpleMiic(), and _size_.
| gum::learning::SimpleMiic::SimpleMiic | ( | SimpleMiic && | from | ) |
move constructor
Definition at line 77 of file SimpleMiic.cpp.
References gum::ApproximationScheme::ApproximationScheme(), SimpleMiic(), and _size_.
|
override |
destructor
Definition at line 83 of file SimpleMiic.cpp.
References SimpleMiic().
|
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 852 of file SimpleMiic.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_(), isOrientable_(), and orientationMiic_().
|
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 838 of file SimpleMiic.cpp.
References _existsDirectedPath_(), gum::ArcGraphPart::existsArc(), and gum::ArcGraphPart::parents().
Referenced by _orientingVstructureMiic_().
Definition at line 1057 of file SimpleMiic.cpp.
References _latentCouples_.
Referenced by _orientingVstructureMiic_(), and orientationLatents_().
|
private |
Definition at line 889 of file SimpleMiic.cpp.
References _arcProbas_, _existsNonTrivialDirectedPath_(), _isNotLatentCouple_(), _latentCouples_, gum::DiGraph::addArc(), gum::EdgeGraphPart::eraseEdge(), and gum::ArcGraphPart::existsArc().
Referenced by orientationMiic_().
|
private |
Definition at line 984 of file SimpleMiic.cpp.
References _arcProbas_, _existsDirectedPath_(), _latentCouples_, gum::DiGraph::addArc(), gum::Set< Key >::empty(), gum::EdgeGraphPart::eraseEdge(), and gum::ArcGraphPart::parents().
Referenced by orientationMiic_().
| void gum::learning::SimpleMiic::addConstraints | ( | HashTable< std::pair< NodeId, NodeId >, char > | constraints | ) |
Set a ensemble of constraints for the orientation phase.
Definition at line 834 of file SimpleMiic.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 418 of file SimpleMiic.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 128 of file SimpleMiic.cpp.
References _emptySet_, gum::ApproximationScheme::current_step_, gum::EdgeGraphPart::edges(), gum::EdgeGraphPart::eraseEdge(), findBestContributor_(), GUM_EMIT3, gum::IApproximationSchemeConfiguration::onProgress, gum::learning::CorrectedMutualInformation::score(), gum::Set< Key >::size(), and gum::ApproximationScheme::timer_.
Referenced by learnMixedStructure().
|
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_().
Definition at line 1065 of file SimpleMiic.cpp.
References _initialMarks_.
Referenced by learnPDAG(), and learnStructure().
|
protected |
Definition at line 713 of file SimpleMiic.cpp.
References _existsDirectedPath_(), gum::MixedGraph::boundary(), gum::MixedGraph::mixedOrientedPath(), and gum::ArcGraphPart::parents().
Referenced by propagatesRemainingOrientableEdges_().
|
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 162 of file SimpleMiic.cpp.
References gum::ApproximationScheme::current_step_, gum::EdgeGraphPart::eraseEdge(), findBestContributor_(), GUM_EMIT3, 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().
| const std::vector< Arc > gum::learning::SimpleMiic::latentVariables | ( | ) | const |
get the list of arcs hiding latent variables
Definition at line 820 of file SimpleMiic.cpp.
References _latentCouples_.
| BayesNet< GUM_SCALAR > gum::learning::SimpleMiic::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 827 of file SimpleMiic.cpp.
References gum::learning::DAG2BNLearner::createBN(), and learnStructure().
| MixedGraph gum::learning::SimpleMiic::learnMixedStructure | ( | CorrectedMutualInformation & | mutualInformation, |
| MixedGraph | graph ) |
learns the structure of an Essential Graph
learns the structure of a MixedGraph
| 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 98 of file SimpleMiic.cpp.
References _latentCouples_, gum::ApproximationScheme::current_step_, initiation_(), iteration_(), orientationMiic_(), and gum::ApproximationScheme::timer_.
Referenced by learnPDAG(), and learnStructure().
| MixedGraph gum::learning::SimpleMiic::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 614 of file SimpleMiic.cpp.
References gum::DiGraph::addArc(), gum::Set< Key >::empty(), gum::EdgeGraphPart::eraseEdge(), isForbidenArc_(), learnMixedStructure(), gum::EdgeGraphPart::neighbours(), gum::ArcGraphPart::parents(), propagatesRemainingOrientableEdges_(), and gum::DiGraph::topologicalOrder().
| DAG gum::learning::SimpleMiic::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.
learns the structure of an Bayesian network, ie a DAG, from an Essential graph.
| 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 654 of file SimpleMiic.cpp.
References gum::DAG::addArc(), gum::DiGraph::addArc(), gum::NodeGraphPart::addNodeWithId(), gum::ArcGraphPart::arcs(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::ArcGraphPart::eraseArc(), gum::EdgeGraphPart::eraseEdge(), isForbidenArc_(), learnMixedStructure(), gum::EdgeGraphPart::neighbours(), gum::ArcGraphPart::parents(), propagatesOrientationInChainOfRemainingEdges_(), propagatesRemainingOrientableEdges_(), and gum::DiGraph::topologicalOrder().
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_().
| SimpleMiic & gum::learning::SimpleMiic::operator= | ( | const SimpleMiic & | from | ) |
copy operator
Definition at line 86 of file SimpleMiic.cpp.
References SimpleMiic().
| SimpleMiic & gum::learning::SimpleMiic::operator= | ( | SimpleMiic && | from | ) |
move operator
Definition at line 92 of file SimpleMiic.cpp.
References SimpleMiic().
|
protected |
variant trying to propagate both orientations in a bidirected arc
Definition at line 214 of file SimpleMiic.cpp.
References _isNotLatentCouple_(), _latentCouples_, gum::DiGraph::addArc(), gum::ApproximationScheme::current_step_, gum::ArcGraphPart::directedPath(), gum::ArcGraphPart::eraseArc(), gum::EdgeGraphPart::eraseEdge(), gum::ArcGraphPart::existsArc(), GUM_EMIT3, gum::IApproximationSchemeConfiguration::onProgress, gum::ApproximationScheme::timer_, and unshieldedTriples_().
|
protected |
Orientation phase from the MIIC algorithm, returns a mixed graph that may contain circles.
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 344 of file SimpleMiic.cpp.
References _existsDirectedPath_(), _initialMarks_, _latentCouples_, _orientingVstructureMiic_(), _propagatingOrientationMiic_(), gum::DiGraph::addArc(), gum::HashTable< Key, Val >::begin(), gum::ApproximationScheme::current_step_, gum::HashTable< Key, Val >::end(), gum::ArcGraphPart::eraseArc(), gum::EdgeGraphPart::eraseEdge(), gum::EdgeGraphPart::existsEdge(), GUM_EMIT3, gum::IApproximationSchemeConfiguration::onProgress, gum::ApproximationScheme::timer_, unshieldedTriplesMiic_(), and updateProbaTriples_().
Referenced by learnMixedStructure().
|
overridevirtualinherited |
Returns the period size.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 155 of file approximationScheme_inl.h.
References period_size_.
|
protected |
heuristic for remaining edges when everything else has been tried
Definition at line 746 of file SimpleMiic.cpp.
References gum::DiGraph::addArc(), gum::Set< Key >::begin(), gum::ArcGraphPart::children(), gum::Set< Key >::clear(), gum::Set< Key >::contains(), gum::EdgeGraphPart::edges(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), gum::EdgeGraphPart::eraseEdge(), gum::Set< Key >::insert(), gum::EdgeGraphPart::neighbours(), propagatesRemainingOrientableEdges_(), and gum::Set< Key >::size().
Referenced by learnStructure().
|
protected |
Propagates the orientation from a node to its neighbours.
Definition at line 789 of file SimpleMiic.cpp.
References _latentCouples_, gum::DiGraph::addArc(), gum::EdgeGraphPart::eraseEdge(), isOrientable_(), gum::EdgeGraphPart::neighbours(), and propagatesRemainingOrientableEdges_().
Referenced by learnPDAG(), learnStructure(), propagatesOrientationInChainOfRemainingEdges_(), and propagatesRemainingOrientableEdges_().
|
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().
|
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})|
Definition at line 494 of file SimpleMiic.cpp.
References gum::EdgeGraphPart::existsEdge(), gum::EdgeGraphPart::neighbours(), and gum::learning::CorrectedMutualInformation::score().
Referenced by orientationLatents_().
|
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
Definition at line 531 of file SimpleMiic.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.
Definition at line 572 of file SimpleMiic.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 299 of file SimpleMiic.h.
Referenced by _orientingVstructureMiic_(), and _propagatingOrientationMiic_().
|
private |
Initial marks for the orientation phase, used to convey constraints.
Definition at line 302 of file SimpleMiic.h.
Referenced by addConstraints(), isForbidenArc_(), and orientationMiic_().
|
private |
an empty vector of arcs
Definition at line 293 of file SimpleMiic.h.
Referenced by _isNotLatentCouple_(), _orientingVstructureMiic_(), _propagatingOrientationMiic_(), latentVariables(), learnMixedStructure(), orientationLatents_(), orientationMiic_(), and propagatesRemainingOrientableEdges_().
|
private |
Fixes the maximum log that we accept in exponential computations.
Definition at line 289 of file SimpleMiic.h.
Referenced by SimpleMiic(), SimpleMiic(), and findBestContributor_().
|
private |
size of the database
Definition at line 296 of file SimpleMiic.h.
Referenced by SimpleMiic(), SimpleMiic(), SimpleMiic(), and SimpleMiic().
|
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().
|
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().
|
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().