aGrUM 2.3.2
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-2025 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-2025 *
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
67 class KNML: private IndependenceTest {
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 virtual KNML* clone() const;
130
132 virtual ~KNML();
133
135
136
137 // ##########################################################################
139 // ##########################################################################
140
142
144 KNML& operator=(const KNML& from);
145
148
150
151
152 // ##########################################################################
154 // ##########################################################################
156
159
162
165
176
179
181
188
191
194
197
199 virtual void clear();
200
202 virtual void clearCache();
203
205 virtual void useCache(const bool on_off);
206
208
212
215
217
218
219 protected:
221
224 virtual double score_(const IdCondSet& idset) final;
225
226
227#ifndef DOXYGEN_SHOULD_SKIP_THIS
228
229 private:
231 VariableLog2ParamComplexity _param_complexity_;
232
233#endif /* DOXYGEN_SHOULD_SKIP_THIS */
234 };
235
236 } /* namespace learning */
237
238} /* namespace gum */
239
240// include the inlined functions if necessary
241#ifndef GUM_NO_INLINE
243#endif /* GUM_NO_INLINE */
244
245#endif /* GUM_LEARNING_K_NML_H */
the class for computing the log2 of the parametric complexity of an r-ary multinomial variable
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
virtual void setMinNbRowsPerThread(const std::size_t nb) const
changes the number min of rows a thread should process in a multithreading context
IndependenceTest(const DBRowGeneratorParser &parser, const Prior &external_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 setRanges(const std::vector< std::pair< std::size_t, std::size_t > > &new_ranges)
sets new ranges to perform the counts used by the independence test
double score(const NodeId var1, const NodeId var2)
returns the score of a pair of nodes
virtual std::size_t minNbRowsPerThread() const
returns the minimum of rows that each thread should process
virtual Size getNumberOfThreads() const
returns the current max number of threads of the scheduler
void clearRanges()
reset the ranges to the one range corresponding to the whole database
virtual void setNumberOfThreads(Size nb)
sets the number max of threads that can be used
const DatabaseTable & database() const
return the database used by the score
const std::vector< std::pair< std::size_t, std::size_t > > & ranges() const
returns the current ranges
virtual bool isGumNumberOfThreadsOverriden() const
indicates whether the user set herself the number of threads
const Bijection< NodeId, std::size_t > & nodeId2Columns() const
return the mapping between the columns of the database and the node ids
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
virtual ~KNML()
destructor
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
virtual double score_(const IdCondSet &idset) final
returns the score for a given IdCondSet
KNML(const KNML &from)
copy constructor
virtual void clear()
clears all the data structures from memory, including the C_n^r cache
virtual KNML * clone() const
virtual copy constructor
virtual void useCache(const bool on_off)
turn on/off the use of the C_n^r cache
KNML(KNML &&from)
move constructor
const std::vector< std::pair< std::size_t, std::size_t > > & ranges() const
returns the current ranges
virtual void clearCache()
clears the current C_n^r cache
the base class for all a priori
Definition prior.h:83
the base class for all the independence tests used for learning
The class for the NML penalty used in MIIC.
include the inlined functions if necessary
Definition CSVParser.h:54
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