aGrUM
3.3.2
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
CIBasedLearning.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
55
#ifndef GUM_CI_BASED_LEARNING_H
56
#define GUM_CI_BASED_LEARNING_H
57
58
#include <vector>
59
60
#include <
agrum/base/stattests/independenceTest.h
>
61
#include <
agrum/BN/learning/ConstraintBasedLearning.h
>
62
63
namespace
gum
{
64
65
namespace
learning
{
66
81
class
GUM_PUBLIC_BN
CIBasedLearning
:
public
ConstraintBasedLearning
{
82
public
:
84
enum class
UCPriority
: uint8_t {
85
Standard,
86
Sorted,
87
};
88
89
// ##########################################################################
91
// ##########################################################################
93
94
CIBasedLearning
();
95
CIBasedLearning
(
const
CIBasedLearning
&);
96
CIBasedLearning
(
CIBasedLearning
&&) noexcept;
97
~
CIBasedLearning
() override;
98
99
CIBasedLearning
& operator=(const
CIBasedLearning
&);
100
CIBasedLearning
& operator=(
CIBasedLearning
&&) noexcept;
101
103
104
// ##########################################################################
106
// ##########################################################################
108
110
void
setIndependenceTest
(
IndependenceTest
& test);
111
113
114
// ##########################################################################
116
// ##########################################################################
118
119
void
setAlpha
(
double
alpha
);
120
double
alpha
() const;
121
123
void
setMaxCondSetSize
(
Size
max_k);
124
126
void
setStable
(
bool
stable);
127
130
void
setExhaustiveSepSet
(
bool
exhaustive);
131
bool
exhaustiveSepSet
() const;
132
134
void
setUCPriority
(
UCPriority
p);
135
UCPriority
ucPriority
() const;
136
138
139
// ##########################################################################
141
// ##########################################################################
143
145
MixedGraph
learnSkeleton
(
MixedGraph
graph
) override;
146
147
// learnMixedStructure() remains pure virtual (inherited from ConstraintBasedLearning)
148
150
151
protected:
152
// separation set entry: conditioning set + p-value that triggered removal
153
struct
SepSetEntry_
{
154
std::vector< NodeId >
cond
;
155
double
pval
{0.0};
156
};
157
158
// ##########################################################################
160
// ##########################################################################
162
164
MixedGraph
orientUnshieldedColliders_(
MixedGraph
graph
);
165
167
void
orientColliderArm_(
MixedGraph
&
graph
,
NodeId
src,
NodeId
dst);
168
172
virtual
void
resolveOrientConflict_(
NodeId
src,
NodeId
dst);
173
175
176
// ##########################################################################
178
// ##########################################################################
179
180
IndependenceTest
*
test_
{
nullptr
};
181
double
alpha_
=
gum::config
().
typed
<
double
>(
"learning"
,
"alpha"
);
182
Size
maxCondSetSize_
=
Size
(-1);
183
bool
stable_
=
true
;
184
bool
exhaustiveSepSet_
=
false
;
185
UCPriority
ucPriority_
=
UCPriority::Standard
;
186
187
HashTable< std::pair< NodeId, NodeId >
,
SepSetEntry_
>
sepSet_
;
188
};
189
190
}
/* namespace learning */
191
192
}
/* namespace gum */
193
194
#endif
/* GUM_CI_BASED_LEARNING_H */
ConstraintBasedLearning.h
Abstract base class for constraint-based structure learning algorithms.
gum::Configuration::typed
T typed(std::string_view section, std::string_view key) const
Value of section.key converted according to its declared type.
Definition
configuration_tpl.h:62
gum::HashTable
The class for generic Hash Tables.
Definition
hashTable.h:640
gum::MixedGraph
Base class for mixed graphs.
Definition
mixedGraph.h:150
gum::learning::CIBasedLearning::ucPriority_
UCPriority ucPriority_
Definition
CIBasedLearning.h:185
gum::learning::CIBasedLearning::test_
IndependenceTest * test_
Definition
CIBasedLearning.h:180
gum::learning::CIBasedLearning::CIBasedLearning
CIBasedLearning(const CIBasedLearning &)
gum::learning::CIBasedLearning::setAlpha
void setAlpha(double alpha)
maximum conditioning set size; Size(-1) = unlimited (default)
Definition
CIBasedLearning.cpp:106
gum::learning::CIBasedLearning::ucPriority
UCPriority ucPriority() const
maximum conditioning set size; Size(-1) = unlimited (default)
Definition
CIBasedLearning.cpp:120
gum::learning::CIBasedLearning::stable_
bool stable_
Definition
CIBasedLearning.h:183
gum::learning::CIBasedLearning::exhaustiveSepSet
bool exhaustiveSepSet() const
maximum conditioning set size; Size(-1) = unlimited (default)
Definition
CIBasedLearning.cpp:116
gum::learning::CIBasedLearning::alpha_
double alpha_
Definition
CIBasedLearning.h:181
gum::learning::CIBasedLearning::setIndependenceTest
void setIndependenceTest(IndependenceTest &test)
inject independence test (non-owning: caller manages lifetime)
Definition
CIBasedLearning.cpp:104
gum::learning::CIBasedLearning::exhaustiveSepSet_
bool exhaustiveSepSet_
Definition
CIBasedLearning.h:184
gum::learning::CIBasedLearning::setUCPriority
void setUCPriority(UCPriority p)
collider candidate ordering (default: Standard)
Definition
CIBasedLearning.cpp:118
gum::learning::CIBasedLearning::CIBasedLearning
CIBasedLearning()
gum::learning::CIBasedLearning::UCPriority
UCPriority
Controls how collider candidates are ordered before orientation.
Definition
CIBasedLearning.h:84
gum::learning::CIBasedLearning::UCPriority::Standard
@ Standard
process triples in natural traversal order
Definition
CIBasedLearning.h:85
gum::learning::CIBasedLearning::setMaxCondSetSize
void setMaxCondSetSize(Size max_k)
maximum conditioning set size; Size(-1) = unlimited (default)
Definition
CIBasedLearning.cpp:110
gum::learning::CIBasedLearning::learnSkeleton
MixedGraph learnSkeleton(MixedGraph graph) override
Phase 1: skeleton discovery via conditional independence tests.
Definition
CIBasedLearning.cpp:126
gum::learning::CIBasedLearning::alpha
double alpha() const
maximum conditioning set size; Size(-1) = unlimited (default)
Definition
CIBasedLearning.cpp:108
gum::learning::CIBasedLearning::setStable
void setStable(bool stable)
stable mode: defer edge removals until end of each depth (default: true)
Definition
CIBasedLearning.cpp:112
gum::learning::CIBasedLearning::maxCondSetSize_
Size maxCondSetSize_
Definition
CIBasedLearning.h:182
gum::learning::CIBasedLearning::sepSet_
HashTable< std::pair< NodeId, NodeId >, SepSetEntry_ > sepSet_
Definition
CIBasedLearning.h:187
gum::learning::CIBasedLearning::setExhaustiveSepSet
void setExhaustiveSepSet(bool exhaustive)
exhaustive sepset mode: accumulate union of all separating sets found at each depth,...
Definition
CIBasedLearning.cpp:114
gum::learning::ConstraintBasedLearning::ConstraintBasedLearning
ConstraintBasedLearning()
Definition
ConstraintBasedLearning.cpp:60
gum::learning::IndependenceTest
The base class for all the independence tests used for learning.
Definition
independenceTest.h:61
gum::Size
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition
types.h:74
gum::NodeId
Size NodeId
Type for node ids.
Definition
graphElements.h:117
independenceTest.h
the base class for all the independence tests used for learning
gum::graph
Definition
bayesBall.h:79
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
gum::config
Configuration & config()
A short name for Configuration::instance() : gum::config().epsilonStandard(). It is not inline so tha...
Definition
configuration.cpp:888
gum::learning::CIBasedLearning::SepSetEntry_
Definition
CIBasedLearning.h:153
gum::learning::CIBasedLearning::SepSetEntry_::cond
std::vector< NodeId > cond
Definition
CIBasedLearning.h:154
gum::learning::CIBasedLearning::SepSetEntry_::pval
double pval
Definition
CIBasedLearning.h:155
aGrUM
3.3.2
© PHW&CG&others - 2022
DoXyGeN 1.18.0