acfx 0.3.7.dev1__tar.gz → 0.3.7.dev2__tar.gz

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.
Files changed (26) hide show
  1. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/PKG-INFO +1 -1
  2. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/evaluation/loss.py +22 -5
  3. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx.egg-info/PKG-INFO +1 -1
  4. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/pyproject.toml +1 -1
  5. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/LICENSE +0 -0
  6. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/ACFX.py +0 -0
  7. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/AcfxCustom.py +0 -0
  8. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/AcfxEBM.py +0 -0
  9. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/AcfxLinear.py +0 -0
  10. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/RandomSearchCounterOptimizer.py +0 -0
  11. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/__init__.py +0 -0
  12. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/abstract/ModelBasedCounterOptimizer.py +0 -0
  13. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/abstract/OptimizerType.py +0 -0
  14. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/abstract/__init__.py +0 -0
  15. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/evaluation/EBMCounterOptimizer.py +0 -0
  16. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/evaluation/LogisticRegressionCounterOptimizer.py +0 -0
  17. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/evaluation/__init__.py +0 -0
  18. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/evaluation/bayesian_model.py +0 -0
  19. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/evaluation/ccfs.py +0 -0
  20. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/evaluation/multi_dataset_evaluation.py +0 -0
  21. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx/evaluation/utils.py +0 -0
  22. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx.egg-info/SOURCES.txt +0 -0
  23. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx.egg-info/dependency_links.txt +0 -0
  24. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx.egg-info/requires.txt +0 -0
  25. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/acfx.egg-info/top_level.txt +0 -0
  26. {acfx-0.3.7.dev1 → acfx-0.3.7.dev2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: acfx
3
- Version: 0.3.7.dev1
3
+ Version: 0.3.7.dev2
4
4
  Summary: Actionable Counterfactual eXplanations
5
5
  Author-email: Szymon Bobek <szymon.bobek@gmail.com>, Piotr Kubacki <piotr.kubacki00@gmail.com>
6
6
  License: MIT
@@ -27,13 +27,30 @@ def compute_causal_penalty_bayesian_adjacency(samples, model : DiscreteBayesianN
27
27
  cpd = model.get_cpds(node)
28
28
  if not cpd:
29
29
  continue
30
+ try:
31
+ node_idx = nodes.index(node)
32
+ node_value = int(np.round(sample[node_idx]))
30
33
 
31
- # Get parent values for this sample
32
- parent_values = [int(sample[nodes.index(p)]) for p in parents]
33
- node_value = sample[nodes.index(node)]
34
+ # Get parent values for this sample
35
+ parent_values = [int(np.round(sample[nodes.index(p)])) for p in parents]
34
36
 
35
- # Find probability from CPD
36
- prob = cpd.get_value(**{node: int(node_value), **dict(zip(parents, parent_values))})
37
+ node_cardinality = cpd.variable_card
38
+
39
+ node_value = max(0, min(node_value, node_cardinality - 1))
40
+
41
+ for i, p_name in enumerate(parents):
42
+ parent_cardinality = model.get_cardinality(p_name)
43
+ parent_values[i] = max(0, min(parent_values[i], parent_cardinality - 1))
44
+
45
+ # Find probability from CPD
46
+ kwargs = {node: node_value}
47
+ for p_name, p_val in zip(parents, parent_values):
48
+ kwargs[p_name] = p_val
49
+
50
+ prob = cpd.get_value(**kwargs)
51
+ except (IndexError, ValueError) as e:
52
+ prob = 1e-8
53
+ print(f'compute_causal_penalty_bayesian_adjacency: {e}')
37
54
  if np.abs(prob) < 1e-8:
38
55
  prob = 1e-8
39
56
  sample_penalty += -np.log(prob)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: acfx
3
- Version: 0.3.7.dev1
3
+ Version: 0.3.7.dev2
4
4
  Summary: Actionable Counterfactual eXplanations
5
5
  Author-email: Szymon Bobek <szymon.bobek@gmail.com>, Piotr Kubacki <piotr.kubacki00@gmail.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "acfx"
7
- version = "0.3.7dev1"
7
+ version = "0.3.7dev2"
8
8
  description = "Actionable Counterfactual eXplanations"
9
9
  readme = "README.md"
10
10
  authors = [
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes