aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
structuralMetrics.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_LEARNING_STRUCTURAL_METRICS_H
51#define GUM_LEARNING_STRUCTURAL_METRICS_H
52
54#include <agrum/BN/BayesNet.h>
55
56namespace gum {
57
64 public:
65 // ##########################################################################
67 // ##########################################################################
69
72
75
77
78 // ##########################################################################
80 // ##########################################################################
83 void compare(const DiGraph& ref, const DiGraph& test);
85 void compare(const UndiGraph& ref, const UndiGraph& test);
87 void compare(const PDAG& ref, const PDAG& test);
91 template < typename GS1, typename GS2 >
92 void compare(const BayesNet< GS1 >& ref, const BayesNet< GS2 >& test);
95 template < GUM_Numeric GUM_SCALAR >
96 void compare(const BayesNet< GUM_SCALAR >& ref, const PDAG& test);
99 template < GUM_Numeric GUM_SCALAR >
100 void compare(const PDAG& ref, const BayesNet< GUM_SCALAR >& test);
101
103 double tp_skeleton() const;
104 double fp_skeleton() const;
105 double fn_skeleton() const;
106 double tn_skeleton() const;
107 double precision_skeleton() const;
108 double recall_skeleton() const;
109 double f_score_skeleton() const;
110 double shd_skeleton() const;
111
113 double tp() const;
114 double fp() const;
115 double fn() const;
116 double tn() const;
117 double precision() const;
118 double recall() const;
119 double f_score() const;
120 double shd() const;
121
122 // Causal measure for DAGs
123 double sid(const DAG& ref, const DAG& test) const;
125 template < typename GS1, typename GS2 >
126 double sid(const BayesNet< GS1 >& ref, const BayesNet< GS2 >& test) const;
127
128 private:
130 /* __________________________________________________
131 * | \predicted | | | |
132 * |true\ | --> | --- | X |
133 * |--------------|-----------|-----------|-----------|
134 * | --> | true arc |wrong edge |wrong none |
135 * | | mis. arc | arc | arc |
136 * |--------------|-----------|-----------|-----------|
137 * | --- |wrong arc | true edge |wrong none |
138 * | | edge | | edge |
139 * |--------------|-----------|-----------|-----------|
140 * | X |wrong arc |wrong edge | true none |
141 * | | none | none | |
142 * | _____________|___________|___________|___________|
143 *
144 */
149 // double _precision_, _recall_, _f_score_;
150
153 };
154
155} /* namespace gum */
156
159
160#endif /* GUM_LEARNING_STRUCTURAL_METRICS_H */
Class representing Bayesian networks.
Base classes for partially directed acyclic graphs.
Class representing a Bayesian network.
Definition BayesNet.h:93
Base class for dag.
Definition DAG.h:121
Base class for all oriented graphs.
Definition diGraph.h:132
Base class for partially directed acyclic graphs.
Definition PDAG.h:130
double _wrong_edge_arc_
Confusion matrix.
StructuralMetrics()
default constructor
double fn_skeleton() const
Confusion matrix.
double tp() const
Measures for the graphs.
double _true_arc_
Confusion matrix.
void compare(const UndiGraph &ref, const UndiGraph &test)
compare two UndiGraphs (nodes matched by NodeId, no alignment)
double _misoriented_arc_
Confusion matrix.
double recall_skeleton() const
Confusion matrix.
void compare(const PDAG &ref, const PDAG &test)
compare two PDAGs (nodes matched by NodeId, no alignment)
double precision() const
Confusion matrix.
double shd_skeleton() const
Confusion matrix.
double recall() const
Confusion matrix.
double _wrong_edge_none_
Confusion matrix.
double fp() const
Confusion matrix.
double _wrong_arc_edge_
Confusion matrix.
double fn() const
Confusion matrix.
double _wrong_none_arc_
Confusion matrix.
double sid(const BayesNet< GS1 > &ref, const BayesNet< GS2 > &test) const
SID overload comparing the DAGs of two BNs (NOT their essential graphs).
double tn() const
Confusion matrix.
double fp_skeleton() const
Confusion matrix.
void compare(const PDAG &ref, const BayesNet< GUM_SCALAR > &test)
compare the essential graph of a BN with a reference PDAG (nodes matched by NodeId,...
void compare(const BayesNet< GS1 > &ref, const BayesNet< GS2 > &test)
compare two BNs via their essential graphs (nodes matched by variable name). For a DAG-level BN compa...
double precision_skeleton() const
Confusion matrix.
double f_score_skeleton() const
Confusion matrix.
void compare(const BayesNet< GUM_SCALAR > &ref, const PDAG &test)
compare a PDAG with the essential graph of a reference BN (nodes matched by NodeId,...
double f_score() const
Confusion matrix.
double _wrong_arc_none_
Confusion matrix.
void compare(const DiGraph &ref, const DiGraph &test)
compare two DiGraphs (nodes matched by NodeId, no alignment)
double _true_edge_
Confusion matrix.
double _wrong_none_edge_
Confusion matrix.
~StructuralMetrics()
destructor
double _true_none_
Confusion matrix.
double sid(const DAG &ref, const DAG &test) const
Confusion matrix.
Size _size_
Number of nodes in the compared graphs (set by compare()).
double shd() const
Confusion matrix.
double tp_skeleton() const
Measures for the skeleton, aka graph without orientations.
double tn_skeleton() const
Confusion matrix.
Base class for undirected graphs.
Definition undiGraph.h:130
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
gum is the global namespace for all aGrUM entities
Definition agrum.h:46