aGrUM
3.3.2
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
DAG2BNLearner.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 by *
5
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
6
* - Christophe GONZALES(_at_AMU) *
7
* *
8
* The aGrUM/pyAgrum library is free software; you can redistribute it *
9
* and/or modify it under the terms of either : *
10
* *
11
* - the GNU Lesser General Public License as published by *
12
* the Free Software Foundation, either version 3 of the License, *
13
* or (at your option) any later version, *
14
* - the MIT license (MIT), *
15
* - or both in dual license, as here. *
16
* *
17
* (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18
* *
19
* This aGrUM/pyAgrum library is distributed in the hope that it will be *
20
* useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26
* OTHER DEALINGS IN THE SOFTWARE. *
27
* *
28
* See LICENCES for more details. *
29
* *
30
* SPDX-FileCopyrightText: Copyright 2005-2026 *
31
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
32
* - Christophe GONZALES(_at_AMU) *
33
* SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34
* *
35
* Contact : info_at_agrum_dot_org *
36
* homepage : http://agrum.gitlab.io *
37
* gitlab : https://gitlab.com/agrumery/agrum *
38
* *
39
****************************************************************************/
40
41
48
#ifndef GUM_LEARNING_DAG_2_BN_LEARNER_H
49
#define GUM_LEARNING_DAG_2_BN_LEARNER_H
50
51
#include <algorithm>
52
#include <string>
53
#include <vector>
54
55
#include <
agrum/agrum.h
>
56
57
#include <
agrum/BN/learning/paramUtils/EMApproximationScheme.h
>
58
#include <
agrum/BN/learning/paramUtils/paramEstimator.h
>
59
60
namespace
gum
{
61
62
namespace
learning
{
63
70
class
GUM_PUBLIC_BN
DAG2BNLearner
:
public
EMApproximationScheme
{
71
public
:
72
// ##########################################################################
74
// ##########################################################################
76
78
DAG2BNLearner
();
79
81
DAG2BNLearner
(
const
DAG2BNLearner
& from);
82
84
DAG2BNLearner
(
DAG2BNLearner
&& from)
noexcept
;
85
87
[[nodiscard]]
virtual
DAG2BNLearner
*
clone
()
const
;
88
90
~DAG2BNLearner
()
override
;
91
93
94
95
// ##########################################################################
97
// ##########################################################################
98
100
102
DAG2BNLearner
&
operator=
(
const
DAG2BNLearner
& from);
103
105
DAG2BNLearner
&
operator=
(
DAG2BNLearner
&& from)
noexcept
;
106
108
109
110
// ##########################################################################
112
// ##########################################################################
114
123
DAG2BNLearner
&
setNoise
(
const
double
noise);
124
126
template
< GUM_Numeric GUM_SCALAR =
double
>
127
static
BayesNet< GUM_SCALAR >
createBN
(
ParamEstimator
& estimator,
const
DAG
& dag);
128
138
template
< GUM_Numeric GUM_SCALAR =
double
>
139
BayesNet< GUM_SCALAR >
createBNwithEM
(
ParamEstimator
& bootstrap_estimator,
140
ParamEstimator
& EM_estimator,
141
const
DAG
& dag);
142
161
template
< GUM_Numeric GUM_SCALAR >
162
BayesNet< GUM_SCALAR >
createBNwithEM
(
ParamEstimator
& bootstrap_estimator,
163
ParamEstimator
& EM_estimator,
164
const
BayesNet< GUM_SCALAR >& bn);
165
183
template
< GUM_Numeric GUM_SCALAR >
184
BayesNet< GUM_SCALAR >
createBNwithEM
(
ParamEstimator
& bootstrap_estimator,
185
ParamEstimator
& EM_estimator,
186
BayesNet< GUM_SCALAR >&& bn);
187
189
EMApproximationScheme
&
approximationScheme
();
190
192
193
#ifndef DOXYGEN_SHOULD_SKIP_THIS
194
195
private
:
204
double
noiseEM_{0.1};
205
207
212
double
log_likelihood_EM_{0.0};
213
223
unsigned
int
max_nb_dec_likelihood_iter_{3};
224
226
228
template
< GUM_Numeric GUM_SCALAR =
double
>
229
static
void
_probaVarReordering_(
gum::Tensor< GUM_SCALAR >
& pot,
230
const
gum::Tensor< GUM_SCALAR >
& other_pot);
231
233
244
template
< GUM_Numeric GUM_SCALAR =
double
>
245
BayesNet< GUM_SCALAR >
246
_createBN_(ParamEstimator& estimator,
const
DAG& dag,
const
bool
compute_log_likelihood);
256
template
< GUM_Numeric GUM_SCALAR >
257
BayesNet< GUM_SCALAR > _performEM_(ParamEstimator& bootstrap_estimator,
258
ParamEstimator& EM_estimator,
259
BayesNet< GUM_SCALAR >&& bn);
260
261
262
#endif
/* DOXYGEN_SHOULD_SKIP_THIS */
263
};
264
265
}
/* namespace learning */
266
267
}
/* namespace gum */
268
270
#include <
agrum/BN/learning/paramUtils/DAG2BNLearner_tpl.h
>
271
272
// include the inlined functions if necessary
273
#ifndef GUM_NO_INLINE
274
# include <
agrum/BN/learning/paramUtils/DAG2BNLearner_inl.h
>
275
#endif
/* GUM_NO_INLINE */
276
277
#endif
/* GUM_LEARNING_DAG_2_BN_LEARNER_H */
DAG2BNLearner_inl.h
A class that, given a structure and a parameter estimator returns a full Bayes net.
DAG2BNLearner_tpl.h
A class that, given a structure and a parameter estimator returns a full Bayes net.
EMApproximationScheme.h
A class for parameterizing EM's parameter learning approximations.
agrum.h
gum::DAG
Base class for dag.
Definition
DAG.h:121
gum::Tensor
aGrUM's Tensor is a multi-dimensional array with tensor operators.
Definition
tensor.h:85
gum::learning::DAG2BNLearner::createBN
static BayesNet< GUM_SCALAR > createBN(ParamEstimator &estimator, const DAG &dag)
create a BN from a DAG using a one pass generator (typically ML)
Definition
DAG2BNLearner_tpl.h:76
gum::learning::DAG2BNLearner::approximationScheme
EMApproximationScheme & approximationScheme()
returns the approximation policy of the EM learning algorithm
gum::learning::DAG2BNLearner::clone
virtual DAG2BNLearner * clone() const
virtual copy constructor
gum::learning::DAG2BNLearner::setNoise
DAG2BNLearner & setNoise(const double noise)
sets the noise amount used to perturb the initial CPTs used by EM
gum::learning::DAG2BNLearner::DAG2BNLearner
DAG2BNLearner()
default constructor
gum::learning::DAG2BNLearner::DAG2BNLearner
DAG2BNLearner(DAG2BNLearner &&from) noexcept
move constructor
gum::learning::DAG2BNLearner::DAG2BNLearner
DAG2BNLearner(const DAG2BNLearner &from)
copy constructor
gum::learning::DAG2BNLearner::operator=
DAG2BNLearner & operator=(DAG2BNLearner &&from) noexcept
move operator
gum::learning::DAG2BNLearner::createBNwithEM
BayesNet< GUM_SCALAR > createBNwithEM(ParamEstimator &bootstrap_estimator, ParamEstimator &EM_estimator, const DAG &dag)
creates a BN with a given structure (dag) using the EM algorithm
Definition
DAG2BNLearner_tpl.h:132
gum::learning::DAG2BNLearner::operator=
DAG2BNLearner & operator=(const DAG2BNLearner &from)
copy operator
gum::learning::DAG2BNLearner::~DAG2BNLearner
~DAG2BNLearner() override
destructor
gum::learning::EMApproximationScheme::EMApproximationScheme
EMApproximationScheme(bool verbosity=false)
initializes the EM parameter learning approximation with the min rate criterion
Definition
EMApproximationScheme.cpp:55
gum::learning::ParamEstimator
The base class for estimating parameters of CPTs.
Definition
paramEstimator.h:67
gum::learning
include the inlined functions if necessary
Definition
CSVParser.h:55
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
paramEstimator.h
the base class for estimating parameters of CPTs
aGrUM
3.3.2
© PHW&CG&others - 2022
DoXyGeN 1.18.0