![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
A class that, given a structure and a parameter estimator returns a full Bayes net. More...
#include <agrum/BN/learning/paramUtils/DAG2BNLearner.h>
Public Attributes | |
Signaler3< Size, double, double > | onProgress |
Progression, error and time. More... | |
Signaler1< std::string > | onStop |
Criteria messageApproximationScheme. More... | |
Public Member Functions | |
Constructors / Destructors | |
DAG2BNLearner (const allocator_type &alloc=allocator_type()) | |
default constructor More... | |
DAG2BNLearner (const DAG2BNLearner< ALLOC > &from) | |
copy constructor More... | |
DAG2BNLearner (const DAG2BNLearner< ALLOC > &from, const allocator_type &alloc) | |
copy constructor with a given allocator More... | |
DAG2BNLearner (DAG2BNLearner< ALLOC > &&from) | |
move constructor More... | |
DAG2BNLearner (DAG2BNLearner< ALLOC > &&from, const allocator_type &alloc) | |
move constructor with a given allocator More... | |
virtual DAG2BNLearner< ALLOC > * | clone () const |
virtual copy constructor More... | |
virtual DAG2BNLearner< ALLOC > * | clone (const allocator_type &alloc) const |
virtual copy constructor with a given allocator More... | |
virtual | ~DAG2BNLearner () |
destructor More... | |
Operators | |
DAG2BNLearner< ALLOC > & | operator= (const DAG2BNLearner< ALLOC > &from) |
copy operator More... | |
DAG2BNLearner< ALLOC > & | operator= (DAG2BNLearner< ALLOC > &&from) |
move operator 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 | |
using | allocator_type = ALLOC< NodeId > |
type for the allocators passed in arguments of methods More... | |
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... | |
Accessors / Modifiers | |
template<typename GUM_SCALAR = double> | |
BayesNet< GUM_SCALAR > | createBN (ParamEstimator< ALLOC > &bootstrap_estimator, ParamEstimator< ALLOC > &general_estimator, const DAG &dag) |
create a BN from a DAG using a two pass generator (typically EM) More... | |
ApproximationScheme & | approximationScheme () |
returns the approximation policy of the learning algorithm More... | |
allocator_type | getAllocator () const |
returns the allocator used by the score More... | |
template<typename GUM_SCALAR = double> | |
static BayesNet< GUM_SCALAR > | createBN (ParamEstimator< ALLOC > &estimator, const DAG &dag) |
create a BN from a DAG using a one pass generator (typically ML) More... | |
A class that, given a structure and a parameter estimator returns a full Bayes net.
Definition at line 51 of file DAG2BNLearner.h.
using gum::learning::DAG2BNLearner< ALLOC >::allocator_type = ALLOC< NodeId > |
type for the allocators passed in arguments of methods
Definition at line 54 of file DAG2BNLearner.h.
|
stronginherited |
The different state of an approximation scheme.
Enumerator | |
---|---|
Undefined | |
Continue | |
Epsilon | |
Rate | |
Limit | |
TimeLimit | |
Stopped |
Definition at line 64 of file IApproximationSchemeConfiguration.h.
gum::learning::DAG2BNLearner< ALLOC >::DAG2BNLearner | ( | const allocator_type & | alloc = allocator_type() | ) |
default constructor
gum::learning::DAG2BNLearner< ALLOC >::DAG2BNLearner | ( | const DAG2BNLearner< ALLOC > & | from | ) |
copy constructor
Definition at line 68 of file DAG2BNLearner_tpl.h.
References gum::learning::genericBNLearner::Database::Database().
gum::learning::DAG2BNLearner< ALLOC >::DAG2BNLearner | ( | const DAG2BNLearner< ALLOC > & | from, |
const allocator_type & | alloc | ||
) |
copy constructor with a given allocator
gum::learning::DAG2BNLearner< ALLOC >::DAG2BNLearner | ( | DAG2BNLearner< ALLOC > && | from | ) |
move constructor
Definition at line 85 of file DAG2BNLearner_tpl.h.
References gum::learning::genericBNLearner::Database::Database().
gum::learning::DAG2BNLearner< ALLOC >::DAG2BNLearner | ( | DAG2BNLearner< ALLOC > && | from, |
const allocator_type & | alloc | ||
) |
move constructor with a given allocator
|
virtual |
destructor
Definition at line 115 of file DAG2BNLearner_tpl.h.
References gum::learning::genericBNLearner::Database::Database().
INLINE ApproximationScheme & gum::learning::DAG2BNLearner< ALLOC >::approximationScheme | ( | ) |
returns the approximation policy of the learning algorithm
Definition at line 264 of file DAG2BNLearner_tpl.h.
|
virtual |
virtual copy constructor
Definition at line 108 of file DAG2BNLearner_tpl.h.
References gum::learning::genericBNLearner::Database::Database().
|
virtual |
virtual copy constructor with a given allocator
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 208 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
static |
create a BN from a DAG using a one pass generator (typically ML)
create a BN
Definition at line 159 of file DAG2BNLearner_tpl.h.
References gum::learning::genericBNLearner::Database::Database().
BayesNet< GUM_SCALAR > gum::learning::DAG2BNLearner< ALLOC >::createBN | ( | ParamEstimator< ALLOC > & | bootstrap_estimator, |
ParamEstimator< ALLOC > & | general_estimator, | ||
const DAG & | dag | ||
) |
create a BN from a DAG using a two pass generator (typically EM)
create a BN
The bootstrap estimator is used once to provide an inital BN. This one is used by the second estimator. The later is exploited in a loop until the stopping condition is met (max of relative error on every parameter<epsilon)
Definition at line 208 of file DAG2BNLearner_tpl.h.
References gum::learning::genericBNLearner::Database::Database().
|
virtualinherited |
Returns the current running time in second.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 115 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Disable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 53 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Disable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 94 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Disable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 118 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Disable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 74 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Enable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 56 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Enable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 97 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Enable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 121 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Enable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 77 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns the value of epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 50 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE DAG2BNLearner< ALLOC >::allocator_type gum::learning::DAG2BNLearner< ALLOC >::getAllocator | ( | ) | const |
returns the allocator used by the score
Definition at line 41 of file DAG2BNLearner_tpl.h.
|
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 157 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Initialise the scheme.
Definition at line 168 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns true if stopping criterion on epsilon is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 60 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns true if stopping criterion on max iterations is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 101 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns true if stopping criterion on timeout is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 125 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns true if stopping criterion on epsilon rate is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 81 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns the criterion on number of iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 91 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns the timeout (in seconds).
Implements gum::IApproximationSchemeConfiguration.
Definition at line 112 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Returns the approximation scheme message.
Definition at line 38 of file IApproximationSchemeConfiguration_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns the value of the minimal epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 71 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns the number of iterations.
OperationNotAllowed | Raised if the scheme did not perform. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 148 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
DAG2BNLearner< ALLOC > & gum::learning::DAG2BNLearner< ALLOC >::operator= | ( | const DAG2BNLearner< ALLOC > & | from | ) |
copy operator
Definition at line 122 of file DAG2BNLearner_tpl.h.
References gum::learning::genericBNLearner::Database::Database().
DAG2BNLearner< ALLOC > & gum::learning::DAG2BNLearner< ALLOC >::operator= | ( | DAG2BNLearner< ALLOC > && | from | ) |
move operator
Definition at line 130 of file DAG2BNLearner_tpl.h.
References gum::learning::genericBNLearner::Database::Database().
|
virtualinherited |
Returns the period size.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 134 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Returns the remaining burn in.
Definition at line 191 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 42 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 84 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 105 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 63 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 128 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Set the verbosity on (true) or off (false).
v | If true, then verbosity is turned on. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 137 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Returns true if we are at the beginning of a period (compute error is mandatory).
Definition at line 178 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns the approximation scheme state.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 143 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Stop the approximation scheme.
Definition at line 200 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Update the scheme w.r.t the new error and increment steps.
incr | The new increment steps. |
Definition at line 187 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns true if verbosity is enabled.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 139 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
protectedinherited |
Number of iterations before checking stopping criteria.
Definition at line 413 of file approximationScheme.h.
|
protectedinherited |
Current epsilon.
Definition at line 368 of file approximationScheme.h.
|
protectedinherited |
Current rate.
Definition at line 374 of file approximationScheme.h.
|
protectedinherited |
The current state.
Definition at line 383 of file approximationScheme.h.
|
protectedinherited |
The current step.
Definition at line 377 of file approximationScheme.h.
|
protectedinherited |
If true, the threshold convergence is enabled.
Definition at line 392 of file approximationScheme.h.
|
protectedinherited |
If true, the maximum iterations stopping criterion is enabled.
Definition at line 410 of file approximationScheme.h.
|
protectedinherited |
If true, the timeout is enabled.
Definition at line 404 of file approximationScheme.h.
|
protectedinherited |
If true, the minimal threshold for epsilon rate is enabled.
Definition at line 398 of file approximationScheme.h.
|
protectedinherited |
Threshold for convergence.
Definition at line 389 of file approximationScheme.h.
|
protectedinherited |
The scheme history, used only if verbosity == true.
Definition at line 386 of file approximationScheme.h.
|
protectedinherited |
Last epsilon value.
Definition at line 371 of file approximationScheme.h.
|
protectedinherited |
The maximum iterations.
Definition at line 407 of file approximationScheme.h.
|
protectedinherited |
The timeout.
Definition at line 401 of file approximationScheme.h.
|
protectedinherited |
Threshold for the epsilon rate.
Definition at line 395 of file approximationScheme.h.
Progression, error and time.
Definition at line 58 of file IApproximationSchemeConfiguration.h.
|
inherited |
Criteria messageApproximationScheme.
Definition at line 61 of file IApproximationSchemeConfiguration.h.
|
protectedinherited |
Checking criteria frequency.
Definition at line 416 of file approximationScheme.h.
|
protectedinherited |
The timer.
Definition at line 380 of file approximationScheme.h.
|
protectedinherited |
If true, verbosity is enabled.
Definition at line 419 of file approximationScheme.h.