aGrUM 3.2.0
a C++ library for (probabilistic) graphical models
paramEstimator_inl.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#pragma once
42
43
49
50#include <agrum/BN/learning/paramUtils/paramEstimator.h> // to ease IDE parser
51#ifndef DOXYGEN_SHOULD_SKIP_THIS
52
54
55namespace gum {
56
57 namespace learning {
58
59 // Copy and move constructors are defined out-of-line in
60 // paramEstimator.cpp on purpose -- see the comment there.
61
63 INLINE void ParamEstimator::clear() { counter_.clear(); }
64
67
70
74 }
75
78 INLINE void ParamEstimator::setMinNbRowsPerThread(const std::size_t nb) const {
80 }
81
83 INLINE std::size_t ParamEstimator::minNbRowsPerThread() const {
85 }
86
88 INLINE const std::vector< std::pair< std::size_t, std::size_t > >&
90 return counter_.ranges();
91 }
92
94 INLINE std::vector< double > ParamEstimator::parameters(const NodeId target_node) {
95 return parameters(target_node, empty_nodevect_);
96 }
97
99 INLINE std::pair< std::vector< double >, double >
101 return parametersAndLogLikelihood(target_node, empty_nodevect_);
102 }
103
105 INLINE const Bijection< NodeId, std::size_t >& ParamEstimator::nodeId2Columns() const {
106 return counter_.nodeId2Columns();
107 }
108
110 INLINE const DatabaseTable& ParamEstimator::database() const { return counter_.database(); }
111
112
113 } /* namespace learning */
114
115} /* namespace gum */
116
117#endif /* DOXYGEN_SHOULD_SKIP_THIS */
bool isGumNumberOfThreadsOverriden() const override
indicates whether the class containing this ThreadNumberManager set its own number of threads
Size getNumberOfThreads() const override
returns the current max number of threads used by the class containing this ThreadNumberManager
The class representing a tabular database as used by learning tasks.
RecordCounter counter_
the record counter used to parse the database
virtual void setMinNbRowsPerThread(const std::size_t nb) const
changes the number min of rows a thread should process in a multithreading context
const Bijection< NodeId, std::size_t > & nodeId2Columns() const
returns the mapping from ids to column positions in the database
bool isGumNumberOfThreadsOverriden() const override
indicates whether the user set herself the number of threads
const std::vector< NodeId > empty_nodevect_
an empty vector of nodes, used for empty conditioning
Size getNumberOfThreads() const override
returns the current max number of threads of the scheduler
virtual void clear()
clears all the data structures from memory
std::pair< std::vector< double >, double > parametersAndLogLikelihood(const NodeId target_node)
returns the parameters of a CPT as well as its log-likelihood
const std::vector< std::pair< std::size_t, std::size_t > > & ranges() const
returns the current ranges
std::vector< double > parameters(const NodeId target_node)
returns the CPT's parameters corresponding to a given target node
void setNumberOfThreads(Size nb) override
sets the number max of threads that can be used
const DatabaseTable & database() const
returns the database on which we perform the counts
virtual std::size_t minNbRowsPerThread() const
returns the minimum of rows that each thread should process
std::size_t minNbRowsPerThread() const
returns the minimum of rows that each thread should process
const std::vector< std::pair< std::size_t, std::size_t > > & ranges() const
returns the current ranges
const DatabaseTable & database() const
returns the database on which we perform the counts
void clear()
clears all the last database-parsed counting from memory
const Bijection< NodeId, std::size_t > & nodeId2Columns() const
returns the mapping from ids to column positions in the database
void setMinNbRowsPerThread(const std::size_t nb) const
changes the number min of rows a thread should process in a multithreading context
void setNumberOfThreads(Size nb) override
sets the number max of threads that can be used
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Size NodeId
Type for node ids.
include the inlined functions if necessary
Definition CSVParser.h:55
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
the base class for estimating parameters of CPTs