aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
kNML.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
49#ifndef GUM_LEARNING_K_NML_H
50#define GUM_LEARNING_K_NML_H
51
52#include <vector>
53
56
57namespace gum {
58
59 namespace learning {
60
61
68 public:
69 // ##########################################################################
71 // ##########################################################################
73
75
96 const Prior& prior,
97 const std::vector< std::pair< std::size_t, std::size_t > >& ranges,
98 const Bijection< NodeId, std::size_t >& nodeId2columns
100
101
103
118 const Prior& prior,
119 const Bijection< NodeId, std::size_t >& nodeId2columns
121
123 KNML(const KNML& from);
124
126 KNML(KNML&& from);
127
129 [[nodiscard]] virtual KNML* clone() const;
130
132 ~KNML() override;
133
135
136
137 // ##########################################################################
139 // ##########################################################################
140
142
144 KNML& operator=(const KNML& from);
145
148
150
151
152 // ##########################################################################
154 // ##########################################################################
156
158 double score(NodeId var1, NodeId var2);
159
161 double score(NodeId var1, NodeId var2, const std::vector< NodeId >& rhs_ids);
162
164 void clear() override;
165
167 void clearCache() override;
168
170 void useCache(const bool on_off) override;
171
173
174
175#ifndef DOXYGEN_SHOULD_SKIP_THIS
176
177 private:
179 VariableLog2ParamComplexity _param_complexity_;
180
182 double _score_(const IdCondSet& idset);
183
184#endif /* DOXYGEN_SHOULD_SKIP_THIS */
185 };
186
187 } /* namespace learning */
188
189} /* namespace gum */
190
191// include the inlined functions if necessary
192#ifndef GUM_NO_INLINE
194#endif /* GUM_NO_INLINE */
195
196#endif /* GUM_LEARNING_K_NML_H */
Common counting infrastructure for independence tests and KNML scoring.
the class for computing the log2 of the parametric complexity of an r-ary multinomial variable
const std::vector< std::pair< std::size_t, std::size_t > > & ranges() const
returns the current ranges
CachedContingencyCounter(const DBRowGeneratorParser &parser, const Prior &prior, const std::vector< std::pair< std::size_t, std::size_t > > &ranges, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
the class used to read a row in the database and to transform it into a set of DBRow instances that c...
A class for storing a pair of sets of NodeIds, the second one corresponding to a conditional set.
Definition idCondSet.h:214
KNML & operator=(KNML &&from)
move operator
KNML(const DBRowGeneratorParser &parser, const Prior &prior, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
KNML & operator=(const KNML &from)
copy operator
KNML(const DBRowGeneratorParser &parser, const Prior &prior, const std::vector< std::pair< std::size_t, std::size_t > > &ranges, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
void clearCache() override
clears the current C_n^r cache
~KNML() override
destructor
void clear() override
clears all the data structures from memory, including the C_n^r cache
KNML(const KNML &from)
copy constructor
void useCache(const bool on_off) override
turn on/off the use of the C_n^r cache
virtual KNML * clone() const
virtual copy constructor
double score(NodeId var1, NodeId var2, const std::vector< NodeId > &rhs_ids)
returns the kNML penalty for a pair of nodes given conditioning nodes
KNML(KNML &&from)
move constructor
double score(NodeId var1, NodeId var2)
returns the kNML penalty for a pair of nodes
the base class for all a priori
Definition prior.h:81
Size NodeId
Type for node ids.
The class for the NML penalty used in MIIC.
include the inlined functions if necessary
Definition CSVParser.h:55
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
the class for computing the log2 of the parametric complexity of an r-ary multinomial variable