aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
GTestPolicy.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
50
#ifndef GUM_MULTI_DIM_FUNCTION_GRAPH_G_TEST_POLICY_H
51
#define GUM_MULTI_DIM_FUNCTION_GRAPH_G_TEST_POLICY_H
52
// ============================================================================
53
#include <
agrum/FMDP/learning/core/chiSquare.h
>
54
#include <
agrum/FMDP/learning/core/contingencyTable.h
>
55
#include <
agrum/FMDP/learning/core/testPolicy/ITestPolicy.h
>
56
#include <
agrum/FMDP/learning/core/tupleHashFunc.h
>
57
58
// ============================================================================
59
60
namespace
gum
{
61
62
// template <typename GUM_ELEMENT>
63
// using ConTab = ContingencyTable<Idx, GUM_ELEMENT>;
64
73
template
<
typename
GUM_ELEMENT >
74
class
GTestPolicy
final:
public
ITestPolicy
< GUM_ELEMENT > {
75
public
:
76
// ############################################################################
78
// ############################################################################
80
81
// ============================================================================
83
// ============================================================================
84
GTestPolicy
();
85
86
// ============================================================================
88
// ============================================================================
89
~GTestPolicy
()
override
;
90
91
// ============================================================================
93
// ============================================================================
94
void
*
operator
new
(
size_t
s);
95
96
void
operator
delete
(
void
* p);
97
99
100
// ############################################################################
102
// ############################################################################
104
105
// ============================================================================
107
// ============================================================================
108
void
addObservation
(
Idx
iattr, GUM_ELEMENT ivalue)
override
;
109
111
112
113
// ############################################################################
115
// ############################################################################
117
118
// ============================================================================
121
// ============================================================================
122
bool
isTestRelevant
()
const override
;
123
124
// ============================================================================
126
// ============================================================================
127
void
computeScore
()
const override
;
128
129
// ============================================================================
131
// ============================================================================
132
double
score
()
const override
;
133
134
// ============================================================================
136
// ============================================================================
137
double
secondaryscore
()
const override
;
138
139
141
142
143
// ############################################################################
145
// ############################################################################
147
148
// ============================================================================
150
// ============================================================================
151
void
add
(
const
GTestPolicy< GUM_ELEMENT >
& src);
152
153
// ============================================================================
156
// ============================================================================
157
const
ContingencyTable< Idx, GUM_ELEMENT >
&
ct
()
const
;
158
160
161
162
// ############################################################################
164
// ############################################################################
166
167
std::string
toString
()
const
;
168
170
171
private
:
173
ContingencyTable< Idx, GUM_ELEMENT >
_conTab_
;
174
mutable
double
_GStat_
;
175
};
176
177
}
// End of namespace gum
178
179
#include <
agrum/FMDP/learning/core/testPolicy/GTestPolicy_tpl.h
>
180
181
#endif
/* GUM_MULTI_DIM_FUNCTION_GRAPH_G_TEST_POLICY_H */
GTestPolicy_tpl.h
Template implementations for the GTestPolicy class.
ITestPolicy.h
Headers of the ITestPolicy.
chiSquare.h
Headers of the ChiSquare class.
gum::ContingencyTable< Idx, GUM_ELEMENT >
gum::GTestPolicy::score
double score() const override
Returns the performance of current variable according to the test.
Definition
GTestPolicy_tpl.h:111
gum::GTestPolicy::isTestRelevant
bool isTestRelevant() const override
Returns true if enough observation were made so that the test can be relevant.
Definition
GTestPolicy_tpl.h:157
gum::GTestPolicy::GTestPolicy
GTestPolicy()
Constructor.
Definition
GTestPolicy_tpl.h:136
gum::GTestPolicy::addObservation
void addObservation(Idx iattr, GUM_ELEMENT ivalue) override
Comptabilizes the new observation.
Definition
GTestPolicy_tpl.h:69
gum::GTestPolicy::_conTab_
ContingencyTable< Idx, GUM_ELEMENT > _conTab_
The contingency table used to keeps records of all observation.
Definition
GTestPolicy.h:173
gum::GTestPolicy::toString
std::string toString() const
Definition
GTestPolicy_tpl.h:167
gum::GTestPolicy::secondaryscore
double secondaryscore() const override
Returns a second criterion to severe ties.
Definition
GTestPolicy_tpl.h:124
gum::GTestPolicy::_GStat_
double _GStat_
Definition
GTestPolicy.h:174
gum::GTestPolicy::computeScore
void computeScore() const override
Computes the GStat of current variable according to the test.
Definition
GTestPolicy_tpl.h:82
gum::GTestPolicy::add
void add(const GTestPolicy< GUM_ELEMENT > &src)
Performs the merging of current GTestPolicy instance with given instance.
Definition
GTestPolicy_tpl.h:130
gum::GTestPolicy::ct
const ContingencyTable< Idx, GUM_ELEMENT > & ct() const
Returns contingency table (needed for the merging of GTestPolicy instances).
Definition
GTestPolicy_tpl.h:162
gum::ITestPolicy::ITestPolicy
ITestPolicy()
Allocators and Deallocators redefinition.
Definition
ITestPolicy_tpl.h:49
contingencyTable.h
Headers of the ContingencyTable class.
gum::Idx
Size Idx
Type for indexes.
Definition
types.h:79
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
tupleHashFunc.h
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0