pyAgrum-nightly 2.1.1.9.dev202506061747485979__cp310-abi3-manylinux2014_aarch64.whl → 2.3.1.9.dev202601031765915415__cp310-abi3-manylinux2014_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyagrum/__init__.py +6 -2
- pyagrum/_pyagrum.so +0 -0
- pyagrum/bnmixture/BNMInference.py +6 -2
- pyagrum/bnmixture/BNMLearning.py +12 -2
- pyagrum/bnmixture/BNMixture.py +6 -2
- pyagrum/bnmixture/__init__.py +6 -2
- pyagrum/bnmixture/notebook.py +6 -2
- pyagrum/causal/_CausalFormula.py +6 -2
- pyagrum/causal/_CausalModel.py +6 -2
- pyagrum/causal/__init__.py +6 -2
- pyagrum/causal/_causalImpact.py +6 -2
- pyagrum/causal/_dSeparation.py +6 -2
- pyagrum/causal/_doAST.py +6 -2
- pyagrum/causal/_doCalculus.py +6 -2
- pyagrum/causal/_doorCriteria.py +6 -2
- pyagrum/causal/_exceptions.py +6 -2
- pyagrum/causal/_types.py +6 -2
- pyagrum/causal/causalEffectEstimation/_CausalEffectEstimation.py +6 -2
- pyagrum/causal/causalEffectEstimation/_IVEstimators.py +6 -2
- pyagrum/causal/causalEffectEstimation/_RCTEstimators.py +6 -2
- pyagrum/causal/causalEffectEstimation/__init__.py +6 -2
- pyagrum/causal/causalEffectEstimation/_backdoorEstimators.py +6 -2
- pyagrum/causal/causalEffectEstimation/_causalBNEstimator.py +6 -2
- pyagrum/causal/causalEffectEstimation/_frontdoorEstimators.py +6 -2
- pyagrum/causal/causalEffectEstimation/_learners.py +6 -2
- pyagrum/causal/causalEffectEstimation/_utils.py +6 -2
- pyagrum/causal/notebook.py +8 -3
- pyagrum/clg/CLG.py +6 -2
- pyagrum/clg/GaussianVariable.py +6 -2
- pyagrum/clg/SEM.py +6 -2
- pyagrum/clg/__init__.py +6 -2
- pyagrum/clg/canonicalForm.py +6 -2
- pyagrum/clg/constants.py +6 -2
- pyagrum/clg/forwardSampling.py +6 -2
- pyagrum/clg/learning.py +6 -2
- pyagrum/clg/notebook.py +6 -2
- pyagrum/clg/variableElimination.py +6 -2
- pyagrum/common.py +7 -3
- pyagrum/config.py +7 -2
- pyagrum/ctbn/CIM.py +6 -2
- pyagrum/ctbn/CTBN.py +6 -2
- pyagrum/ctbn/CTBNGenerator.py +6 -2
- pyagrum/ctbn/CTBNInference.py +6 -2
- pyagrum/ctbn/CTBNLearner.py +6 -2
- pyagrum/ctbn/SamplesStats.py +6 -2
- pyagrum/ctbn/StatsIndepTest.py +6 -2
- pyagrum/ctbn/__init__.py +6 -2
- pyagrum/ctbn/constants.py +6 -2
- pyagrum/ctbn/notebook.py +6 -2
- pyagrum/deprecated.py +6 -2
- pyagrum/explain/_ComputationCausal.py +75 -0
- pyagrum/explain/_ComputationConditional.py +48 -0
- pyagrum/explain/_ComputationMarginal.py +48 -0
- pyagrum/explain/_CustomShapleyCache.py +110 -0
- pyagrum/explain/_Explainer.py +176 -0
- pyagrum/explain/_Explanation.py +70 -0
- pyagrum/explain/_FIFOCache.py +54 -0
- pyagrum/explain/_ShallCausalValues.py +204 -0
- pyagrum/explain/_ShallConditionalValues.py +155 -0
- pyagrum/explain/_ShallMarginalValues.py +155 -0
- pyagrum/explain/_ShallValues.py +296 -0
- pyagrum/explain/_ShapCausalValues.py +208 -0
- pyagrum/explain/_ShapConditionalValues.py +126 -0
- pyagrum/explain/_ShapMarginalValues.py +191 -0
- pyagrum/explain/_ShapleyValues.py +298 -0
- pyagrum/explain/__init__.py +81 -0
- pyagrum/explain/_explGeneralizedMarkovBlanket.py +152 -0
- pyagrum/explain/_explIndependenceListForPairs.py +146 -0
- pyagrum/explain/_explInformationGraph.py +264 -0
- pyagrum/explain/notebook/__init__.py +54 -0
- pyagrum/explain/notebook/_bar.py +142 -0
- pyagrum/explain/notebook/_beeswarm.py +174 -0
- pyagrum/explain/notebook/_showShapValues.py +97 -0
- pyagrum/explain/notebook/_waterfall.py +220 -0
- pyagrum/explain/shapley.py +225 -0
- pyagrum/lib/__init__.py +6 -2
- pyagrum/lib/_colors.py +6 -2
- pyagrum/lib/bn2graph.py +6 -2
- pyagrum/lib/bn2roc.py +6 -2
- pyagrum/lib/bn2scores.py +6 -2
- pyagrum/lib/bn_vs_bn.py +6 -2
- pyagrum/lib/cn2graph.py +6 -2
- pyagrum/lib/discreteTypeProcessor.py +99 -81
- pyagrum/lib/discretizer.py +6 -2
- pyagrum/lib/dynamicBN.py +6 -2
- pyagrum/lib/explain.py +17 -492
- pyagrum/lib/export.py +6 -2
- pyagrum/lib/id2graph.py +6 -2
- pyagrum/lib/image.py +6 -2
- pyagrum/lib/ipython.py +6 -2
- pyagrum/lib/mrf2graph.py +6 -2
- pyagrum/lib/notebook.py +6 -2
- pyagrum/lib/proba_histogram.py +6 -2
- pyagrum/lib/utils.py +6 -2
- pyagrum/pyagrum.py +976 -126
- pyagrum/skbn/_MBCalcul.py +6 -2
- pyagrum/skbn/__init__.py +6 -2
- pyagrum/skbn/_learningMethods.py +6 -2
- pyagrum/skbn/_utils.py +6 -2
- pyagrum/skbn/bnclassifier.py +6 -2
- pyagrum_nightly-2.1.1.9.dev202506061747485979.dist-info/LICENSE → pyagrum_nightly-2.3.1.9.dev202601031765915415.dist-info/LICENSE.md +3 -1
- pyagrum_nightly-2.3.1.9.dev202601031765915415.dist-info/LICENSES/LGPL-3.0-or-later.txt +304 -0
- pyagrum_nightly-2.3.1.9.dev202601031765915415.dist-info/LICENSES/MIT.txt +18 -0
- {pyagrum_nightly-2.1.1.9.dev202506061747485979.dist-info → pyagrum_nightly-2.3.1.9.dev202601031765915415.dist-info}/METADATA +3 -1
- pyagrum_nightly-2.3.1.9.dev202601031765915415.dist-info/RECORD +107 -0
- {pyagrum_nightly-2.1.1.9.dev202506061747485979.dist-info → pyagrum_nightly-2.3.1.9.dev202601031765915415.dist-info}/WHEEL +1 -1
- pyagrum/lib/shapley.py +0 -657
- pyagrum_nightly-2.1.1.9.dev202506061747485979.dist-info/LICENSE.LGPL +0 -165
- pyagrum_nightly-2.1.1.9.dev202506061747485979.dist-info/LICENSE.MIT +0 -17
- pyagrum_nightly-2.1.1.9.dev202506061747485979.dist-info/RECORD +0 -83
pyagrum/clg/notebook.py
CHANGED
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
26
26
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
27
27
|
# #
|
|
28
|
-
# See
|
|
29
|
-
#
|
|
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 #
|
|
30
34
|
# #
|
|
31
35
|
# Contact : info_at_agrum_dot_org #
|
|
32
36
|
# homepage : http://agrum.gitlab.io #
|
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
26
26
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
27
27
|
# #
|
|
28
|
-
# See
|
|
29
|
-
#
|
|
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 #
|
|
30
34
|
# #
|
|
31
35
|
# Contact : info_at_agrum_dot_org #
|
|
32
36
|
# homepage : http://agrum.gitlab.io #
|
pyagrum/common.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
__version__ = '2.
|
|
1
|
+
__version__ = '2.3.1.9'
|
|
2
2
|
__license__ = __doc__
|
|
3
3
|
__project_url__ = 'https://agrum.org'
|
|
4
4
|
__project_name__ = 'pyAgrum'
|
|
@@ -45,8 +45,12 @@ def about():
|
|
|
45
45
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
46
46
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
47
47
|
# #
|
|
48
|
-
# See
|
|
49
|
-
#
|
|
48
|
+
# See LICENCES for more details. #
|
|
49
|
+
# #
|
|
50
|
+
# SPDX-FileCopyrightText: Copyright 2005-2025 #
|
|
51
|
+
# - Pierre-Henri WUILLEMIN(_at_LIP6) #
|
|
52
|
+
# - Christophe GONZALES(_at_AMU) #
|
|
53
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later OR MIT #
|
|
50
54
|
# #
|
|
51
55
|
# Contact : info_at_agrum_dot_org #
|
|
52
56
|
# homepage : http://agrum.gitlab.io #
|
pyagrum/config.py
CHANGED
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
26
26
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
27
27
|
# #
|
|
28
|
-
# See
|
|
29
|
-
#
|
|
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 #
|
|
30
34
|
# #
|
|
31
35
|
# Contact : info_at_agrum_dot_org #
|
|
32
36
|
# homepage : http://agrum.gitlab.io #
|
|
@@ -59,6 +63,7 @@ class PyAgrumConfiguration(metaclass=GumSingleton):
|
|
|
59
63
|
|
|
60
64
|
Examples
|
|
61
65
|
--------
|
|
66
|
+
>>> import pyagrum as gum
|
|
62
67
|
>>> gum.config["dynamicBN", "default_graph_size"] = 10
|
|
63
68
|
>>> gum.config["dynamicBN", "default_graph_size"]
|
|
64
69
|
"10"
|
pyagrum/ctbn/CIM.py
CHANGED
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
26
26
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
27
27
|
# #
|
|
28
|
-
# See
|
|
29
|
-
#
|
|
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 #
|
|
30
34
|
# #
|
|
31
35
|
# Contact : info_at_agrum_dot_org #
|
|
32
36
|
# homepage : http://agrum.gitlab.io #
|
pyagrum/ctbn/CTBN.py
CHANGED
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
26
26
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
27
27
|
# #
|
|
28
|
-
# See
|
|
29
|
-
#
|
|
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 #
|
|
30
34
|
# #
|
|
31
35
|
# Contact : info_at_agrum_dot_org #
|
|
32
36
|
# homepage : http://agrum.gitlab.io #
|
pyagrum/ctbn/CTBNGenerator.py
CHANGED
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
26
26
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
27
27
|
# #
|
|
28
|
-
# See
|
|
29
|
-
#
|
|
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 #
|
|
30
34
|
# #
|
|
31
35
|
# Contact : info_at_agrum_dot_org #
|
|
32
36
|
# homepage : http://agrum.gitlab.io #
|
pyagrum/ctbn/CTBNInference.py
CHANGED
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
26
26
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
27
27
|
# #
|
|
28
|
-
# See
|
|
29
|
-
#
|
|
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 #
|
|
30
34
|
# #
|
|
31
35
|
# Contact : info_at_agrum_dot_org #
|
|
32
36
|
# homepage : http://agrum.gitlab.io #
|
pyagrum/ctbn/CTBNLearner.py
CHANGED
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
26
26
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
27
27
|
# #
|
|
28
|
-
# See
|
|
29
|
-
#
|
|
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 #
|
|
30
34
|
# #
|
|
31
35
|
# Contact : info_at_agrum_dot_org #
|
|
32
36
|
# homepage : http://agrum.gitlab.io #
|
pyagrum/ctbn/SamplesStats.py
CHANGED
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
26
26
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
27
27
|
# #
|
|
28
|
-
# See
|
|
29
|
-
#
|
|
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 #
|
|
30
34
|
# #
|
|
31
35
|
# Contact : info_at_agrum_dot_org #
|
|
32
36
|
# homepage : http://agrum.gitlab.io #
|
pyagrum/ctbn/StatsIndepTest.py
CHANGED
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
26
26
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
27
27
|
# #
|
|
28
|
-
# See
|
|
29
|
-
#
|
|
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 #
|
|
30
34
|
# #
|
|
31
35
|
# Contact : info_at_agrum_dot_org #
|
|
32
36
|
# homepage : http://agrum.gitlab.io #
|
pyagrum/ctbn/__init__.py
CHANGED
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
26
26
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
27
27
|
# #
|
|
28
|
-
# See
|
|
29
|
-
#
|
|
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 #
|
|
30
34
|
# #
|
|
31
35
|
# Contact : info_at_agrum_dot_org #
|
|
32
36
|
# homepage : http://agrum.gitlab.io #
|
pyagrum/ctbn/constants.py
CHANGED
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
26
26
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
27
27
|
# #
|
|
28
|
-
# See
|
|
29
|
-
#
|
|
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 #
|
|
30
34
|
# #
|
|
31
35
|
# Contact : info_at_agrum_dot_org #
|
|
32
36
|
# homepage : http://agrum.gitlab.io #
|
pyagrum/ctbn/notebook.py
CHANGED
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
26
26
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
27
27
|
# #
|
|
28
|
-
# See
|
|
29
|
-
#
|
|
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 #
|
|
30
34
|
# #
|
|
31
35
|
# Contact : info_at_agrum_dot_org #
|
|
32
36
|
# homepage : http://agrum.gitlab.io #
|
pyagrum/deprecated.py
CHANGED
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
|
|
26
26
|
# OTHER DEALINGS IN THE SOFTWARE. #
|
|
27
27
|
# #
|
|
28
|
-
# See
|
|
29
|
-
#
|
|
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 #
|
|
30
34
|
# #
|
|
31
35
|
# Contact : info_at_agrum_dot_org #
|
|
32
36
|
# homepage : http://agrum.gitlab.io #
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
import pyagrum as gum
|
|
42
|
+
|
|
43
|
+
# Calculations
|
|
44
|
+
import numpy as np
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class CausalComputation:
|
|
48
|
+
@staticmethod
|
|
49
|
+
def _outOfCoalition(tau: list[int], inter: list[int]) -> list[int]:
|
|
50
|
+
# Returns the intersection of the parameter inter and the complement of the coalition tau.
|
|
51
|
+
return [i for i in inter if i not in tau]
|
|
52
|
+
|
|
53
|
+
@staticmethod
|
|
54
|
+
def _doCalculus(bn: gum.BayesNet, tau: list[int]) -> gum.BayesNet:
|
|
55
|
+
# Creates a new Bayesian Network by removing incoming arcs to the nodes in tau.
|
|
56
|
+
doNetTemplate = gum.BayesNet(bn)
|
|
57
|
+
for i in tau:
|
|
58
|
+
parents = doNetTemplate.parents(i)
|
|
59
|
+
for j in parents:
|
|
60
|
+
doNetTemplate.eraseArc(j, i)
|
|
61
|
+
return doNetTemplate
|
|
62
|
+
|
|
63
|
+
@staticmethod
|
|
64
|
+
def _chgCpt(doNetTemplate: gum.BayesNet, tau: list[int], alpha: list[int]) -> None:
|
|
65
|
+
# Changes the conditional probability tables (CPTs) of the nodes in tau to reflect the values in alpha.
|
|
66
|
+
for i, j in zip(tau, alpha):
|
|
67
|
+
doNetTemplate.cpt(i).fillWith(0.0)
|
|
68
|
+
doNetTemplate.cpt(i)[int(j)] = 1.0
|
|
69
|
+
|
|
70
|
+
@staticmethod
|
|
71
|
+
def _weight(evidces: dict[int, int], count: int, doLazy: gum.LazyPropagation) -> np.ndarray:
|
|
72
|
+
# Returns the evidces probability.
|
|
73
|
+
# The signature must be : Dict[int, int], int, **kwargs
|
|
74
|
+
doLazy.updateEvidence(evidces)
|
|
75
|
+
return doLazy.evidenceProbability() * count
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
import numpy as np
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ConditionalComputation:
|
|
45
|
+
@staticmethod
|
|
46
|
+
def _weight(evidces: dict[int, int], count: int) -> np.ndarray:
|
|
47
|
+
# The signature must be : Dict[int, int], int, **kwargs
|
|
48
|
+
return count
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
import numpy as np
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class MarginalComputation:
|
|
45
|
+
@staticmethod
|
|
46
|
+
def _weight(evidces: dict[int, int], count: int) -> np.ndarray:
|
|
47
|
+
# The signature must be : Dict[int, int], int, **kwargs
|
|
48
|
+
return count
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
|
|
42
|
+
class CustomShapleyCache:
|
|
43
|
+
def __init__(self, max_capacity: int = 1000):
|
|
44
|
+
if max_capacity <= 0:
|
|
45
|
+
raise ValueError("max_capacity must be a positive integer.")
|
|
46
|
+
self._cache = {} # Structure: {longueur_str: { (entier, str): valeur }}
|
|
47
|
+
self._current_k_index = -1 # Pour suivre l'indice k actuel
|
|
48
|
+
self._max_capacity = max_capacity # Capacité maximale du cache en nombre d'éléments
|
|
49
|
+
self._current_size = 0 # Taille actuelle du cache
|
|
50
|
+
|
|
51
|
+
@staticmethod
|
|
52
|
+
def generate_keys(bn, target, feat, nodes):
|
|
53
|
+
key1 = tuple(nodes) # Key1 represents the coalition.
|
|
54
|
+
key2 = tuple(
|
|
55
|
+
n for n in nodes if n != feat
|
|
56
|
+
) # Key2 represents the coalition without the feature which is being evaluated.
|
|
57
|
+
if target is None: # For SHALL Values
|
|
58
|
+
return key1, key2, None
|
|
59
|
+
# Key3 is the coalition without ONE ! node which is not in the minimal conditional set.
|
|
60
|
+
minimal = bn.minimalCondSet(
|
|
61
|
+
target, nodes
|
|
62
|
+
) # Calculates the minimal conditional set for the target node given the nodes.
|
|
63
|
+
diff = next((n for n in nodes if n not in minimal), None)
|
|
64
|
+
if diff is not None:
|
|
65
|
+
key3 = tuple(n for n in nodes if n != diff)
|
|
66
|
+
else:
|
|
67
|
+
key3 = key1
|
|
68
|
+
return key1, key2, key3
|
|
69
|
+
|
|
70
|
+
def get(self, int_key: int, tuple_key: tuple):
|
|
71
|
+
tuple_len = len(tuple_key)
|
|
72
|
+
return self._cache[tuple_len].get((int_key, tuple_key), None)
|
|
73
|
+
|
|
74
|
+
def set(self, int_key: int, tuple_key: tuple, value):
|
|
75
|
+
tuple_len = len(tuple_key)
|
|
76
|
+
if tuple_len not in self._cache:
|
|
77
|
+
self._cache[tuple_len] = {}
|
|
78
|
+
self._current_k_index = tuple_len
|
|
79
|
+
|
|
80
|
+
# If it is the first time we add an entry of this length, we initialize the cache for this length.
|
|
81
|
+
if (int_key, tuple_key) not in self._cache[tuple_len]:
|
|
82
|
+
self._current_size += 1
|
|
83
|
+
self._cache[tuple_len][(int_key, tuple_key)] = value
|
|
84
|
+
|
|
85
|
+
# Check if we need to purge the cache
|
|
86
|
+
if self._current_size > self._max_capacity:
|
|
87
|
+
self._perform_purge()
|
|
88
|
+
|
|
89
|
+
def _perform_purge(self):
|
|
90
|
+
if self._current_k_index < 2:
|
|
91
|
+
return
|
|
92
|
+
|
|
93
|
+
str_len_to_purge = self._current_k_index - 2
|
|
94
|
+
|
|
95
|
+
# Purge all entries with length <= str_len_to_purge
|
|
96
|
+
for length in list(self._cache.keys()):
|
|
97
|
+
if length <= str_len_to_purge:
|
|
98
|
+
self._current_size -= len(self._cache[length])
|
|
99
|
+
del self._cache[length]
|
|
100
|
+
|
|
101
|
+
def __len__(self):
|
|
102
|
+
return self._current_size
|
|
103
|
+
|
|
104
|
+
def __str__(self):
|
|
105
|
+
# Affiche le cache par longueur de clé pour une meilleure visibilité
|
|
106
|
+
items_by_length = {k: len(v) for k, v in self._cache.items()}
|
|
107
|
+
return (
|
|
108
|
+
f"Cache (k={self._current_k_index}, size={self._current_size}/{self._max_capacity}): "
|
|
109
|
+
f"Contents by length: {items_by_length}"
|
|
110
|
+
)
|