aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
structuralComparator.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
50#ifndef GUM_LEARNING_STRUCTURAL_COMPARATOR_H
51#define GUM_LEARNING_STRUCTURAL_COMPARATOR_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);
89 template < typename GS1, typename GS2 >
90 void compare(const BayesNet< GS1 >& ref, const BayesNet< GS2 >& test);
92 template < typename GUM_SCALAR >
93 void compare(const BayesNet< GUM_SCALAR >& ref, const PDAG& test);
95 template < typename GUM_SCALAR >
96 void compare(const PDAG& ref, const BayesNet< GUM_SCALAR >& test);
97
99 double precision_skeleton() const;
100 double recall_skeleton() const;
101 double f_score_skeleton() const;
102
104 double precision() const;
105 double recall() const;
106 double f_score() const;
108
109 private:
111 /* __________________________________________________
112 * | \predicted | | | |
113 * |true\ | --> | --- | X |
114 * |--------------|-----------|-----------|-----------|
115 * | --> | true arc |wrong edge |wrong none |
116 * | | mis. arc | arc | arc |
117 * |--------------|-----------|-----------|-----------|
118 * | --- |wrong arc | true edge |wrong none |
119 * | | edge | | edge |
120 * |--------------|-----------|-----------|-----------|
121 * | X |wrong arc |wrong edge | true none |
122 * | | none | none | |
123 * | _____________|___________|___________|___________|
124 *
125 */
130 // double _precision_, _recall_, _f_score_;
131 };
132
133} /* namespace gum */
134
137
138#endif /* GUM_LEARNING_STRUCTURAL_COMPARATOR_H */
Class representing Bayesian networks.
Base classes for partially directed acyclic graphs.
Class representing a Bayesian network.
Definition BayesNet.h:93
Base class for all oriented graphs.
Definition diGraph.h:130
Base class for partially directed acyclic graphs.
Definition PDAG.h:130
void compare(const BayesNet< GS1 > &ref, const BayesNet< GS2 > &test)
compare two BNs based on their DAG
double _true_edge_
Confusion matrix.
~StructuralComparator()
destructor
double recall() const
compare two DiGraphs
double precision_skeleton() const
Measures for the skeleton, aka graph without orientations.
void compare(const BayesNet< GUM_SCALAR > &ref, const PDAG &test)
compare a PDAG with the essential graph of a reference BN
double precision() const
Measures for the graphs.
void compare(const PDAG &ref, const BayesNet< GUM_SCALAR > &test)
compare the essential graph of a BN with a reference PDAG
double recall_skeleton() const
compare two DiGraphs
void compare(const UndiGraph &ref, const UndiGraph &test)
compare two UndiGraphs
StructuralComparator()
default constructor
void compare(const PDAG &ref, const PDAG &test)
compare two PDAGs
double f_score_skeleton() const
compare two DiGraphs
void compare(const DiGraph &ref, const DiGraph &test)
compare two DiGraphs
double f_score() const
compare two DiGraphs
Base class for undirected graphs.
Definition undiGraph.h:128
gum is the global namespace for all aGrUM entities
Definition agrum.h:46