![]() |
aGrUM
0.16.0
|
The miic learning algorithm. More...
#include <Miic.h>
Public Attributes | |
Signaler3< Size, double, double > | onProgress |
Progression, error and time. More... | |
Signaler1< std::string > | onStop |
Criteria messageApproximationScheme. More... | |
Public Member Functions | |
Miic & | operator= (const Miic &from) |
copy operator More... | |
Miic & | operator= (Miic &&from) |
move operator More... | |
Constructors / Destructors | |
Miic () | |
default constructor More... | |
Miic (int maxLog) | |
default constructor with maxLog More... | |
Miic (const Miic &from) | |
copy constructor More... | |
Miic (Miic &&from) | |
move constructor More... | |
~Miic () | |
destructor More... | |
Accessors / Modifiers | |
MixedGraph | learnMixedStructure (CorrectedMutualInformation<> &I, MixedGraph graph) |
learns the structure of an Essential Graph More... | |
DAG | learnStructure (CorrectedMutualInformation<> &I, MixedGraph graph) |
learns the structure of an Bayesian network, ie a DAG, by first learning an Essential graph and then directing the remaining edges. More... | |
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 More... | |
const std::vector< Arc > | latentVariables () const |
get the list of arcs hiding latent variables More... | |
void | setMiicBehaviour () |
Sets the orientation phase to follow the one of the MIIC algorithm. More... | |
void | set3off2Behaviour () |
Sets the orientation phase to follow the one of the 3off2 algorithm. More... | |
void | addConstraints (HashTable< std::pair< NodeId, NodeId >, char > constraints) |
Set a ensemble of constraints for the orientation phase. More... | |
Getters and setters | |
void | setEpsilon (double eps) |
Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)|. More... | |
double | epsilon () const |
Returns the value of epsilon. More... | |
void | disableEpsilon () |
Disable stopping criterion on epsilon. More... | |
void | enableEpsilon () |
Enable stopping criterion on epsilon. More... | |
bool | isEnabledEpsilon () const |
Returns true if stopping criterion on epsilon is enabled, false otherwise. More... | |
void | setMinEpsilonRate (double rate) |
Given that we approximate f(t), stopping criterion on d/dt(|f(t+1)-f(t)|). More... | |
double | minEpsilonRate () const |
Returns the value of the minimal epsilon rate. More... | |
void | disableMinEpsilonRate () |
Disable stopping criterion on epsilon rate. More... | |
void | enableMinEpsilonRate () |
Enable stopping criterion on epsilon rate. More... | |
bool | isEnabledMinEpsilonRate () const |
Returns true if stopping criterion on epsilon rate is enabled, false otherwise. More... | |
void | setMaxIter (Size max) |
Stopping criterion on number of iterations. More... | |
Size | maxIter () const |
Returns the criterion on number of iterations. More... | |
void | disableMaxIter () |
Disable stopping criterion on max iterations. More... | |
void | enableMaxIter () |
Enable stopping criterion on max iterations. More... | |
bool | isEnabledMaxIter () const |
Returns true if stopping criterion on max iterations is enabled, false otherwise. More... | |
void | setMaxTime (double timeout) |
Stopping criterion on timeout. More... | |
double | maxTime () const |
Returns the timeout (in seconds). More... | |
double | currentTime () const |
Returns the current running time in second. More... | |
void | disableMaxTime () |
Disable stopping criterion on timeout. More... | |
void | enableMaxTime () |
Enable stopping criterion on timeout. More... | |
bool | isEnabledMaxTime () const |
Returns true if stopping criterion on timeout is enabled, false otherwise. More... | |
void | setPeriodSize (Size p) |
How many samples between two stopping is enable. More... | |
Size | periodSize () const |
Returns the period size. More... | |
void | setVerbosity (bool v) |
Set the verbosity on (true) or off (false). More... | |
bool | verbosity () const |
Returns true if verbosity is enabled. More... | |
ApproximationSchemeSTATE | stateApproximationScheme () const |
Returns the approximation scheme state. More... | |
Size | nbrIterations () const |
Returns the number of iterations. More... | |
const std::vector< double > & | history () const |
Returns the scheme history. More... | |
void | initApproximationScheme () |
Initialise the scheme. More... | |
bool | startOfPeriod () |
Returns true if we are at the beginning of a period (compute error is mandatory). More... | |
void | updateApproximationScheme (unsigned int incr=1) |
Update the scheme w.r.t the new error and increment steps. More... | |
Size | remainingBurnIn () |
Returns the remaining burn in. More... | |
void | stopApproximationScheme () |
Stop the approximation scheme. More... | |
bool | continueApproximationScheme (double error) |
Update the scheme w.r.t the new error. More... | |
Getters and setters | |
std::string | messageApproximationScheme () const |
Returns the approximation scheme message. More... | |
Public Types | |
enum | ApproximationSchemeSTATE : char { ApproximationSchemeSTATE::Undefined, ApproximationSchemeSTATE::Continue, ApproximationSchemeSTATE::Epsilon, ApproximationSchemeSTATE::Rate, ApproximationSchemeSTATE::Limit, ApproximationSchemeSTATE::TimeLimit, ApproximationSchemeSTATE::Stopped } |
The different state of an approximation scheme. More... | |
Protected Attributes | |
double | _current_epsilon |
Current epsilon. More... | |
double | _last_epsilon |
Last epsilon value. More... | |
double | _current_rate |
Current rate. More... | |
Size | _current_step |
The current step. More... | |
Timer | _timer |
The timer. More... | |
ApproximationSchemeSTATE | _current_state |
The current state. More... | |
std::vector< double > | _history |
The scheme history, used only if verbosity == true. More... | |
double | _eps |
Threshold for convergence. More... | |
bool | _enabled_eps |
If true, the threshold convergence is enabled. More... | |
double | _min_rate_eps |
Threshold for the epsilon rate. More... | |
bool | _enabled_min_rate_eps |
If true, the minimal threshold for epsilon rate is enabled. More... | |
double | _max_time |
The timeout. More... | |
bool | _enabled_max_time |
If true, the timeout is enabled. More... | |
Size | _max_iter |
The maximum iterations. More... | |
bool | _enabled_max_iter |
If true, the maximum iterations stopping criterion is enabled. More... | |
Size | _burn_in |
Number of iterations before checking stopping criteria. More... | |
Size | _period_size |
Checking criteria frequency. More... | |
bool | _verbosity |
If true, verbosity is enabled. More... | |
Protected Member Functions | |
void | _findBestContributor (NodeId x, NodeId y, const std::vector< NodeId > &ui, const MixedGraph &graph, CorrectedMutualInformation<> &I, Heap< std::pair< std::tuple< NodeId, NodeId, NodeId, std::vector< NodeId > > *, double >, GreaterPairOn2nd > &_rank) |
finds the best contributor node for a pair given a conditioning set More... | |
std::vector< std::pair< std::tuple< NodeId, NodeId, NodeId > *, double > > | _getUnshieldedTriples (const MixedGraph &graph, CorrectedMutualInformation<> &I, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sep_set) |
gets the list of unshielded triples in the graph in decreasing value of |I'(x, y, z|{ui})| More... | |
std::vector< std::tuple< std::tuple< NodeId, NodeId, NodeId > *, double, double, double > > | _getUnshieldedTriplesMIIC (const MixedGraph &graph, CorrectedMutualInformation<> &I, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sep_set, 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 More... | |
std::vector< std::tuple< std::tuple< NodeId, NodeId, NodeId > *, double, double, double > > | _updateProbaTriples (const MixedGraph &graph, std::vector< std::tuple< std::tuple< NodeId, NodeId, NodeId > *, double, double, double > > proba_triples) |
Gets the orientation probabilities like MIIC for the orientation phase. More... | |
void | _propagatesHead (MixedGraph &graph, NodeId node) |
Propagates the orientation from a node to its neighbours. More... | |
Main phases | |
void | _initiation (CorrectedMutualInformation<> &I, MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sep_set, Heap< std::pair< std::tuple< NodeId, NodeId, NodeId, std::vector< NodeId > > *, double >, GreaterPairOn2nd > &_rank) |
Initiation phase. More... | |
void | _iteration (CorrectedMutualInformation<> &I, MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sep_set, Heap< std::pair< std::tuple< NodeId, NodeId, NodeId, std::vector< NodeId > > *, double >, GreaterPairOn2nd > &_rank) |
Iteration phase. More... | |
void | _orientation_3off2 (CorrectedMutualInformation<> &I, MixedGraph &graph, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sep_set) |
Orientation phase from the 3off2 algorithm, returns a CPDAG. More... | |
void | _orientation_latents (CorrectedMutualInformation<> &I, MixedGraph &graph, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sep_set) |
Modified version of the orientation phase that tries to propagate orientations from both orientations in case of a bidirected arc, not used. More... | |
void | _orientation_miic (CorrectedMutualInformation<> &I, MixedGraph &graph, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sep_set) |
Orientation phase from the MIIC algorithm, returns a mixed graph that may contain circles. More... | |
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.
The variant 3off2 is also implemented as proposed by Affeldt and al. in https://doi.org/10.1186/s12859-015-0856-x. Only the orientation phase differs from miic, with a different ranking method and different propagation rules.
|
stronginherited |
The different state of an approximation scheme.
Enumerator | |
---|---|
Undefined | |
Continue | |
Epsilon | |
Rate | |
Limit | |
TimeLimit | |
Stopped |
Definition at line 65 of file IApproximationSchemeConfiguration.h.
gum::learning::Miic::Miic | ( | int | maxLog | ) |
default constructor with maxLog
Definition at line 47 of file Miic.cpp.
gum::learning::Miic::Miic | ( | const Miic & | from | ) |
copy constructor
Definition at line 50 of file Miic.cpp.
gum::learning::Miic::Miic | ( | Miic && | from | ) |
move constructor
Definition at line 55 of file Miic.cpp.
|
private |
checks for directed paths in a graph, consider double arcs like edges
Definition at line 1073 of file Miic.cpp.
References gum::List< Val, Alloc >::empty(), gum::HashTable< Key, Val, Alloc >::exists(), gum::ArcGraphPart::existsArc(), gum::List< Val, Alloc >::front(), gum::HashTable< Key, Val, Alloc >::insert(), gum::ArcGraphPart::parents(), gum::List< Val, Alloc >::popFront(), and gum::List< Val, Alloc >::pushBack().
Referenced by _orientation_3off2(), _orientation_miic(), and _propagatesHead().
|
protected |
finds the best contributor node for a pair given a conditioning set
x | first node |
y | second node |
ui | conditioning set |
I | 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 765 of file Miic.cpp.
References __maxLog, M_LN2, and gum::learning::CorrectedMutualInformation< ALLOC >::score().
Referenced by _initiation(), and _iteration().
|
protected |
gets the list of unshielded triples in the graph in decreasing value of |I'(x, y, z|{ui})|
Definition at line 849 of file Miic.cpp.
References gum::learning::CorrectedMutualInformation< ALLOC >::score().
Referenced by _orientation_3off2(), and _orientation_latents().
|
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 891 of file Miic.cpp.
References _updateProbaTriples(), and gum::learning::CorrectedMutualInformation< ALLOC >::score().
Referenced by _orientation_miic().
|
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.
I | A mutual information instance that will do the computations and has loaded the database. |
graph | the MixedGraph we start from for the learning |
sep_set | the separation set for independent couples, here set to {} |
_rank | the heap of ranks of the algorithm |
Definition at line 151 of file Miic.cpp.
References __empty_set, gum::ApproximationScheme::_current_step, _findBestContributor(), gum::ApproximationScheme::_timer, gum::EdgeGraphPart::edges(), gum::EdgeGraphPart::eraseEdge(), GUM_EMIT3, gum::IApproximationSchemeConfiguration::onProgress, gum::learning::CorrectedMutualInformation< ALLOC >::score(), gum::Set< Key, Alloc >::size(), and gum::Timer::step().
Referenced by learnMixedStructure().
|
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.
I | A mutual information instance that will do the computations and has loaded the database. |
graph | the MixedGraph returned from the previous phase |
sep_set | the separation set for independent couples, built during the iterations of the phase |
_rank | the heap of ranks of the algorithm |
Definition at line 189 of file Miic.cpp.
References gum::ApproximationScheme::_current_step, _findBestContributor(), gum::ApproximationScheme::_timer, gum::EdgeGraphPart::eraseEdge(), GUM_EMIT3, gum::IApproximationSchemeConfiguration::onProgress, gum::learning::CorrectedMutualInformation< ALLOC >::score(), and gum::Timer::step().
Referenced by learnMixedStructure().
|
protected |
Orientation phase from the 3off2 algorithm, returns a CPDAG.
I | A mutual information instance that will do the computations and has loaded the database. |
graph | the MixedGraph returned from the previous phase |
sep_set | the separation set for independent couples, built during the previous phase |
Definition at line 246 of file Miic.cpp.
References __existsDirectedPath(), __initial_marks, __latent_couples, gum::ApproximationScheme::_current_step, _getUnshieldedTriples(), gum::ApproximationScheme::_timer, gum::DiGraph::addArc(), gum::HashTable< Key, Val, Alloc >::begin(), gum::HashTable< Key, Val, Alloc >::end(), gum::ArcGraphPart::eraseArc(), gum::EdgeGraphPart::eraseEdge(), gum::HashTable< Key, Val, Alloc >::exists(), gum::ArcGraphPart::existsArc(), gum::EdgeGraphPart::existsEdge(), GUM_EMIT3, gum::IApproximationSchemeConfiguration::onProgress, and gum::Timer::step().
Referenced by learnMixedStructure().
|
protected |
Modified version of the orientation phase that tries to propagate orientations from both orientations in case of a bidirected arc, not used.
varient trying to propagate both orientations in a bidirected arc
I | A mutual information instance that will do the computations and has loaded the database. |
graph | the MixedGraph returned from the previous phase |
sep_set | the separation set for independent couples, built during the previous phase |
Definition at line 434 of file Miic.cpp.
References __latent_couples, gum::ApproximationScheme::_current_step, _getUnshieldedTriples(), gum::ApproximationScheme::_timer, gum::DiGraph::addArc(), gum::ArcGraphPart::directedPath(), gum::ArcGraphPart::eraseArc(), gum::EdgeGraphPart::eraseEdge(), gum::ArcGraphPart::existsArc(), GUM_EMIT3, gum::IApproximationSchemeConfiguration::onProgress, and gum::Timer::step().
|
protected |
Orientation phase from the MIIC algorithm, returns a mixed graph that may contain circles.
varient using the orientation protocol of MIIC
I | A mutual information instance that will do the computations and has loaded the database. |
graph | the MixedGraph returned from the previous phase |
sep_set | the separation set for independent couples, built during the previous phase |
Definition at line 586 of file Miic.cpp.
References __arc_probas, __existsDirectedPath(), __initial_marks, __latent_couples, gum::ApproximationScheme::_current_step, _getUnshieldedTriplesMIIC(), gum::ApproximationScheme::_timer, _updateProbaTriples(), gum::DiGraph::addArc(), gum::HashTable< Key, Val, Alloc >::begin(), gum::Set< Key, Alloc >::empty(), gum::HashTable< Key, Val, Alloc >::end(), gum::ArcGraphPart::eraseArc(), gum::EdgeGraphPart::eraseEdge(), gum::ArcGraphPart::existsArc(), gum::EdgeGraphPart::existsEdge(), GUM_EMIT3, gum::IApproximationSchemeConfiguration::onProgress, gum::ArcGraphPart::parents(), and gum::Timer::step().
Referenced by learnMixedStructure().
|
protected |
Propagates the orientation from a node to its neighbours.
Definition at line 1019 of file Miic.cpp.
References __existsDirectedPath(), __initial_marks, __latent_couples, gum::DiGraph::addArc(), gum::Set< Key, Alloc >::empty(), gum::EdgeGraphPart::eraseEdge(), gum::HashTable< Key, Val, Alloc >::exists(), gum::EdgeGraphPart::neighbours(), and gum::ArcGraphPart::parents().
Referenced by learnStructure().
|
protected |
Gets the orientation probabilities like MIIC for the orientation phase.
Definition at line 943 of file Miic.cpp.
References __N, and gum::ArcGraphPart::existsArc().
Referenced by _getUnshieldedTriplesMIIC(), and _orientation_miic().
void gum::learning::Miic::addConstraints | ( | HashTable< std::pair< NodeId, NodeId >, char > | constraints | ) |
Set a ensemble of constraints for the orientation phase.
Definition at line 1067 of file Miic.cpp.
References __initial_marks.
Referenced by gum::learning::genericBNLearner::__prepare_miic_3off2().
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 227 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_current_epsilon, gum::ApproximationScheme::_current_rate, gum::ApproximationScheme::_current_state, gum::ApproximationScheme::_current_step, gum::ApproximationScheme::_enabled_eps, gum::ApproximationScheme::_enabled_max_iter, gum::ApproximationScheme::_enabled_max_time, gum::ApproximationScheme::_enabled_min_rate_eps, gum::ApproximationScheme::_eps, gum::ApproximationScheme::_history, gum::ApproximationScheme::_last_epsilon, gum::ApproximationScheme::_max_iter, gum::ApproximationScheme::_max_time, gum::ApproximationScheme::_min_rate_eps, gum::ApproximationScheme::_stopScheme(), gum::ApproximationScheme::_timer, gum::IApproximationSchemeConfiguration::Continue, gum::IApproximationSchemeConfiguration::Epsilon, GUM_EMIT3, GUM_ERROR, gum::IApproximationSchemeConfiguration::Limit, gum::IApproximationSchemeConfiguration::messageApproximationScheme(), gum::IApproximationSchemeConfiguration::onProgress, gum::IApproximationSchemeConfiguration::Rate, gum::ApproximationScheme::startOfPeriod(), gum::ApproximationScheme::stateApproximationScheme(), gum::Timer::step(), gum::IApproximationSchemeConfiguration::TimeLimit, and gum::ApproximationScheme::verbosity().
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), gum::SamplingInference< GUM_SCALAR >::_loopApproxInference(), gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), and gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::makeInference().
|
virtualinherited |
Returns the current running time in second.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 128 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_timer, and gum::Timer::step().
Referenced by gum::learning::genericBNLearner::currentTime().
|
virtualinherited |
Disable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 54 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_eps.
Referenced by gum::learning::genericBNLearner::disableEpsilon().
|
virtualinherited |
Disable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 105 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_iter.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__mcInitApproximationScheme(), gum::learning::genericBNLearner::disableMaxIter(), and gum::learning::GreedyHillClimbing::GreedyHillClimbing().
|
virtualinherited |
Disable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 131 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_time.
Referenced by gum::learning::genericBNLearner::disableMaxTime(), and gum::learning::GreedyHillClimbing::GreedyHillClimbing().
|
virtualinherited |
Disable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 79 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_min_rate_eps.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__mcInitApproximationScheme(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), gum::learning::genericBNLearner::disableMinEpsilonRate(), and gum::learning::GreedyHillClimbing::GreedyHillClimbing().
|
virtualinherited |
Enable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 57 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_eps.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__mcInitApproximationScheme(), and gum::learning::genericBNLearner::enableEpsilon().
|
virtualinherited |
Enable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 108 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_iter.
Referenced by gum::learning::genericBNLearner::enableMaxIter().
|
virtualinherited |
Enable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 134 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_time.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::CNMonteCarloSampling(), and gum::learning::genericBNLearner::enableMaxTime().
|
virtualinherited |
Enable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 84 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_min_rate_eps.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::learning::genericBNLearner::enableMinEpsilonRate().
|
virtualinherited |
Returns the value of epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 51 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_eps.
Referenced by gum::ImportanceSampling< GUM_SCALAR >::_onContextualize(), and gum::learning::genericBNLearner::epsilon().
|
virtualinherited |
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 173 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_history, GUM_ERROR, gum::ApproximationScheme::stateApproximationScheme(), gum::IApproximationSchemeConfiguration::Undefined, and gum::ApproximationScheme::verbosity().
Referenced by gum::learning::genericBNLearner::history().
|
inherited |
Initialise the scheme.
Definition at line 187 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_current_epsilon, gum::ApproximationScheme::_current_rate, gum::ApproximationScheme::_current_state, gum::ApproximationScheme::_current_step, gum::ApproximationScheme::_history, gum::ApproximationScheme::_timer, gum::IApproximationSchemeConfiguration::Continue, and gum::Timer::reset().
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__mcInitApproximationScheme(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), gum::SamplingInference< GUM_SCALAR >::_loopApproxInference(), gum::SamplingInference< GUM_SCALAR >::_onStateChanged(), gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::learning::GreedyHillClimbing::learnStructure(), and gum::learning::LocalSearchWithTabuList::learnStructure().
|
virtualinherited |
Returns true if stopping criterion on epsilon is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 61 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_eps.
Referenced by gum::learning::genericBNLearner::isEnabledEpsilon().
|
virtualinherited |
Returns true if stopping criterion on max iterations is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 112 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_iter.
Referenced by gum::learning::genericBNLearner::isEnabledMaxIter().
|
virtualinherited |
Returns true if stopping criterion on timeout is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 138 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_time.
Referenced by gum::learning::genericBNLearner::isEnabledMaxTime().
|
virtualinherited |
Returns true if stopping criterion on epsilon rate is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 90 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_min_rate_eps.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::learning::genericBNLearner::isEnabledMinEpsilonRate().
const std::vector< Arc > gum::learning::Miic::latentVariables | ( | ) | const |
get the list of arcs hiding latent variables
Definition at line 1049 of file Miic.cpp.
References __latent_couples.
Referenced by gum::learning::genericBNLearner::latentVariables().
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 1057 of file Miic.cpp.
References learnStructure().
MixedGraph gum::learning::Miic::learnMixedStructure | ( | CorrectedMutualInformation<> & | I, |
MixedGraph | graph | ||
) |
learns the structure of an Essential Graph
learns the structure of a MixedGraph
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 113 of file Miic.cpp.
References __latent_couples, __usemiic, gum::ApproximationScheme::_current_step, _initiation(), _iteration(), _orientation_3off2(), _orientation_miic(), gum::ApproximationScheme::_timer, and gum::Timer::reset().
Referenced by gum::learning::genericBNLearner::learnMixedStructure(), and learnStructure().
DAG gum::learning::Miic::learnStructure | ( | CorrectedMutualInformation<> & | I, |
MixedGraph | graph | ||
) |
learns the structure of an Bayesian network, ie 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 987 of file Miic.cpp.
References _propagatesHead(), gum::DAG::addArc(), gum::NodeGraphPart::addNodeWithId(), gum::Set< Key, Alloc >::empty(), learnMixedStructure(), gum::EdgeGraphPart::neighbours(), gum::ArcGraphPart::parents(), and gum::DiGraph::topologicalOrder().
Referenced by gum::learning::genericBNLearner::__learnDAG(), and learnBN().
|
virtualinherited |
Returns the criterion on number of iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 102 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_max_iter.
Referenced by gum::learning::genericBNLearner::maxIter().
|
virtualinherited |
Returns the timeout (in seconds).
Implements gum::IApproximationSchemeConfiguration.
Definition at line 125 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_max_time.
Referenced by gum::learning::genericBNLearner::maxTime().
|
inherited |
Returns the approximation scheme message.
Definition at line 40 of file IApproximationSchemeConfiguration_inl.h.
References gum::IApproximationSchemeConfiguration::Continue, gum::IApproximationSchemeConfiguration::Epsilon, gum::IApproximationSchemeConfiguration::epsilon(), gum::IApproximationSchemeConfiguration::Limit, gum::IApproximationSchemeConfiguration::maxIter(), gum::IApproximationSchemeConfiguration::maxTime(), gum::IApproximationSchemeConfiguration::minEpsilonRate(), gum::IApproximationSchemeConfiguration::Rate, gum::IApproximationSchemeConfiguration::stateApproximationScheme(), gum::IApproximationSchemeConfiguration::Stopped, gum::IApproximationSchemeConfiguration::TimeLimit, and gum::IApproximationSchemeConfiguration::Undefined.
Referenced by gum::ApproximationScheme::_stopScheme(), gum::ApproximationScheme::continueApproximationScheme(), and gum::credal::InferenceEngine< GUM_SCALAR >::getApproximationSchemeMsg().
|
virtualinherited |
Returns the value of the minimal epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 74 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_min_rate_eps.
Referenced by gum::learning::genericBNLearner::minEpsilonRate().
|
virtualinherited |
Returns the number of iterations.
OperationNotAllowed | Raised if the scheme did not perform. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 163 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_current_step, GUM_ERROR, gum::ApproximationScheme::stateApproximationScheme(), and gum::IApproximationSchemeConfiguration::Undefined.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::learning::genericBNLearner::nbrIterations().
move operator
Definition at line 69 of file Miic.cpp.
References gum::learning::GreaterPairOn2nd::operator()().
|
virtualinherited |
Returns the period size.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 149 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_period_size.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::makeInference(), and gum::learning::genericBNLearner::periodSize().
|
inherited |
Returns the remaining burn in.
Definition at line 210 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_burn_in, and gum::ApproximationScheme::_current_step.
void gum::learning::Miic::set3off2Behaviour | ( | ) |
Sets the orientation phase to follow the one of the 3off2 algorithm.
Definition at line 1065 of file Miic.cpp.
References __usemiic.
Referenced by gum::learning::genericBNLearner::use3off2().
|
virtualinherited |
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. |
OutOfLowerBound | Raised if eps < 0. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 43 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_eps, gum::ApproximationScheme::_eps, and GUM_ERROR.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__mcInitApproximationScheme(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsSampling< GUM_SCALAR >::GibbsSampling(), gum::learning::GreedyHillClimbing::GreedyHillClimbing(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::genericBNLearner::setEpsilon().
|
virtualinherited |
Stopping criterion on number of iterations.
If the criterion was disabled it will be enabled.
max | The maximum number of iterations. |
OutOfLowerBound | Raised if max <= 1. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 95 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_iter, gum::ApproximationScheme::_max_iter, and GUM_ERROR.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::genericBNLearner::setMaxIter().
|
virtualinherited |
Stopping criterion on timeout.
If the criterion was disabled it will be enabled.
timeout | The timeout value in seconds. |
OutOfLowerBound | Raised if timeout <= 0.0. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 118 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_time, gum::ApproximationScheme::_max_time, and GUM_ERROR.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::CNMonteCarloSampling(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::genericBNLearner::setMaxTime().
void gum::learning::Miic::setMiicBehaviour | ( | ) |
Sets the orientation phase to follow the one of the MIIC algorithm.
Definition at line 1064 of file Miic.cpp.
References __usemiic.
Referenced by gum::learning::genericBNLearner::useMIIC().
|
virtualinherited |
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. |
OutOfLowerBound | if rate<0 |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 66 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_min_rate_eps, gum::ApproximationScheme::_min_rate_eps, and GUM_ERROR.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsSampling< GUM_SCALAR >::GibbsSampling(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::genericBNLearner::setMinEpsilonRate().
|
virtualinherited |
How many samples between two stopping is enable.
p | The new period value. |
OutOfLowerBound | Raised if p < 1. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 143 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_period_size, and GUM_ERROR.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::CNMonteCarloSampling(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::genericBNLearner::setPeriodSize().
|
virtualinherited |
Set the verbosity on (true) or off (false).
v | If true, then verbosity is turned on. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 152 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_verbosity.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::genericBNLearner::setVerbosity().
|
inherited |
Returns true if we are at the beginning of a period (compute error is mandatory).
Definition at line 197 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_burn_in, gum::ApproximationScheme::_current_step, and gum::ApproximationScheme::_period_size.
Referenced by gum::ApproximationScheme::continueApproximationScheme().
|
virtualinherited |
Returns the approximation scheme state.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 158 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_current_state.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::history(), gum::ApproximationScheme::nbrIterations(), and gum::learning::genericBNLearner::stateApproximationScheme().
|
inherited |
Stop the approximation scheme.
Definition at line 219 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_current_state, gum::ApproximationScheme::_stopScheme(), gum::IApproximationSchemeConfiguration::Continue, and gum::IApproximationSchemeConfiguration::Stopped.
Referenced by gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::learning::GreedyHillClimbing::learnStructure(), and gum::learning::LocalSearchWithTabuList::learnStructure().
|
inherited |
Update the scheme w.r.t the new error and increment steps.
incr | The new increment steps. |
Definition at line 206 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_current_step.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), gum::SamplingInference< GUM_SCALAR >::_loopApproxInference(), gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), and gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::makeInference().
|
virtualinherited |
Returns true if verbosity is enabled.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 154 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_verbosity.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::history(), and gum::learning::genericBNLearner::verbosity().
|
private |
Storing the propabilities for each arc set in the graph.
Definition at line 362 of file Miic.h.
Referenced by _orientation_miic().
|
private |
Initial marks for the orientation phase, used to convey constraints.
Definition at line 365 of file Miic.h.
Referenced by _orientation_3off2(), _orientation_miic(), _propagatesHead(), and addConstraints().
|
private |
an empty vector of arcs
Definition at line 354 of file Miic.h.
Referenced by _orientation_3off2(), _orientation_latents(), _orientation_miic(), _propagatesHead(), latentVariables(), and learnMixedStructure().
|
private |
Fixes the maximum log that we accept in exponential computations.
Definition at line 350 of file Miic.h.
Referenced by _findBestContributor().
|
private |
|
private |
wether to use the miic algorithm or not
Definition at line 359 of file Miic.h.
Referenced by learnMixedStructure(), set3off2Behaviour(), and setMiicBehaviour().
|
protectedinherited |
Number of iterations before checking stopping criteria.
Definition at line 414 of file approximationScheme.h.
Referenced by gum::GibbsSampling< GUM_SCALAR >::burnIn(), gum::GibbsBNdistance< GUM_SCALAR >::burnIn(), gum::ApproximationScheme::remainingBurnIn(), gum::GibbsSampling< GUM_SCALAR >::setBurnIn(), gum::GibbsBNdistance< GUM_SCALAR >::setBurnIn(), and gum::ApproximationScheme::startOfPeriod().
|
protectedinherited |
Current epsilon.
Definition at line 369 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), and gum::ApproximationScheme::initApproximationScheme().
|
protectedinherited |
Current rate.
Definition at line 375 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), and gum::ApproximationScheme::initApproximationScheme().
|
protectedinherited |
The current state.
Definition at line 384 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::_stopScheme(), gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::initApproximationScheme(), gum::ApproximationScheme::stateApproximationScheme(), and gum::ApproximationScheme::stopApproximationScheme().
|
protectedinherited |
The current step.
Definition at line 378 of file approximationScheme.h.
Referenced by _initiation(), _iteration(), _orientation_3off2(), _orientation_latents(), _orientation_miic(), gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::initApproximationScheme(), learnMixedStructure(), gum::ApproximationScheme::nbrIterations(), gum::ApproximationScheme::remainingBurnIn(), gum::ApproximationScheme::startOfPeriod(), and gum::ApproximationScheme::updateApproximationScheme().
|
protectedinherited |
If true, the threshold convergence is enabled.
Definition at line 393 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::disableEpsilon(), gum::ApproximationScheme::enableEpsilon(), gum::ApproximationScheme::isEnabledEpsilon(), and gum::ApproximationScheme::setEpsilon().
|
protectedinherited |
If true, the maximum iterations stopping criterion is enabled.
Definition at line 411 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::disableMaxIter(), gum::ApproximationScheme::enableMaxIter(), gum::ApproximationScheme::isEnabledMaxIter(), and gum::ApproximationScheme::setMaxIter().
|
protectedinherited |
If true, the timeout is enabled.
Definition at line 405 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::disableMaxTime(), gum::ApproximationScheme::enableMaxTime(), gum::ApproximationScheme::isEnabledMaxTime(), and gum::ApproximationScheme::setMaxTime().
|
protectedinherited |
If true, the minimal threshold for epsilon rate is enabled.
Definition at line 399 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::disableMinEpsilonRate(), gum::ApproximationScheme::enableMinEpsilonRate(), gum::ApproximationScheme::isEnabledMinEpsilonRate(), and gum::ApproximationScheme::setMinEpsilonRate().
|
protectedinherited |
Threshold for convergence.
Definition at line 390 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::epsilon(), and gum::ApproximationScheme::setEpsilon().
|
protectedinherited |
The scheme history, used only if verbosity == true.
Definition at line 387 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::history(), and gum::ApproximationScheme::initApproximationScheme().
|
protectedinherited |
Last epsilon value.
Definition at line 372 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme().
|
protectedinherited |
The maximum iterations.
Definition at line 408 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::maxIter(), and gum::ApproximationScheme::setMaxIter().
|
protectedinherited |
The timeout.
Definition at line 402 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::maxTime(), and gum::ApproximationScheme::setMaxTime().
|
protectedinherited |
Threshold for the epsilon rate.
Definition at line 396 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::minEpsilonRate(), and gum::ApproximationScheme::setMinEpsilonRate().
|
protectedinherited |
Checking criteria frequency.
Definition at line 417 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::periodSize(), gum::ApproximationScheme::setPeriodSize(), and gum::ApproximationScheme::startOfPeriod().
|
protectedinherited |
The timer.
Definition at line 381 of file approximationScheme.h.
Referenced by _initiation(), _iteration(), _orientation_3off2(), _orientation_latents(), _orientation_miic(), gum::ApproximationScheme::_stopScheme(), gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::currentTime(), gum::ApproximationScheme::initApproximationScheme(), and learnMixedStructure().
|
protectedinherited |
If true, verbosity is enabled.
Definition at line 420 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::setVerbosity(), and gum::ApproximationScheme::verbosity().
Progression, error and time.
Definition at line 59 of file IApproximationSchemeConfiguration.h.
Referenced by _initiation(), _iteration(), _orientation_3off2(), _orientation_latents(), _orientation_miic(), gum::ApproximationScheme::continueApproximationScheme(), and gum::learning::genericBNLearner::distributeProgress().
|
inherited |
Criteria messageApproximationScheme.
Definition at line 62 of file IApproximationSchemeConfiguration.h.
Referenced by gum::ApproximationScheme::_stopScheme(), and gum::learning::genericBNLearner::distributeStop().