acfx 0.3.6.dev4__tar.gz → 0.3.7.dev1__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.6.dev4 → acfx-0.3.7.dev1}/PKG-INFO +1 -1
  2. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/evaluation/ccfs.py +11 -4
  3. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx.egg-info/PKG-INFO +1 -1
  4. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/pyproject.toml +1 -1
  5. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/LICENSE +0 -0
  6. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/ACFX.py +0 -0
  7. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/AcfxCustom.py +0 -0
  8. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/AcfxEBM.py +0 -0
  9. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/AcfxLinear.py +0 -0
  10. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/RandomSearchCounterOptimizer.py +0 -0
  11. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/__init__.py +0 -0
  12. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/abstract/ModelBasedCounterOptimizer.py +0 -0
  13. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/abstract/OptimizerType.py +0 -0
  14. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/abstract/__init__.py +0 -0
  15. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/evaluation/EBMCounterOptimizer.py +0 -0
  16. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/evaluation/LogisticRegressionCounterOptimizer.py +0 -0
  17. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/evaluation/__init__.py +0 -0
  18. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/evaluation/bayesian_model.py +0 -0
  19. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/evaluation/loss.py +0 -0
  20. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/evaluation/multi_dataset_evaluation.py +0 -0
  21. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx/evaluation/utils.py +0 -0
  22. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx.egg-info/SOURCES.txt +0 -0
  23. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx.egg-info/dependency_links.txt +0 -0
  24. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx.egg-info/requires.txt +0 -0
  25. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/acfx.egg-info/top_level.txt +0 -0
  26. {acfx-0.3.6.dev4 → acfx-0.3.7.dev1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: acfx
3
- Version: 0.3.6.dev4
3
+ Version: 0.3.7.dev1
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
@@ -1,4 +1,5 @@
1
1
  import random
2
+ import uuid
2
3
  from typing import Sequence, Dict, Tuple, Optional, List
3
4
  import traceback
4
5
  import numpy as np
@@ -82,12 +83,18 @@ def __generate_single_cf(query_instance, desired_class, adjacency_matrix, causal
82
83
  return -loss[0, 1]
83
84
 
84
85
  # Initialize Optuna study
85
- study = optuna.create_study(direction='maximize')
86
+ study_name = f"study_{uuid.uuid4().hex}"
87
+ study = optuna.create_study(direction='maximize', storage=None, study_name=study_name)
86
88
 
87
89
  # Define seen_points set to track uniqueness of points
88
90
  seen_points = set()
89
91
 
90
- def is_unique_point(point_dict):
92
+ def is_unique_point(point_dict, pbounds):
93
+ for key, (min_val, max_val) in pbounds.items():
94
+ val = point_dict.get(key)
95
+ if val is None or not (min_val <= val <= max_val):
96
+ return False
97
+
91
98
  point_tuple = tuple(point_dict[key] for key in features_order)
92
99
  if point_tuple in seen_points:
93
100
  return False
@@ -105,7 +112,7 @@ def __generate_single_cf(query_instance, desired_class, adjacency_matrix, causal
105
112
  Xsample = Xdesired.sample(sample_size)
106
113
  for i, r in Xsample.iterrows():
107
114
  candidate_point = dict(r[features_order])
108
- if is_unique_point(candidate_point):
115
+ if is_unique_point(candidate_point, bounds):
109
116
  trial_params = {key: candidate_point[key] for key in features_order}
110
117
  study.enqueue_trial(trial_params)
111
118
  sampled_trials += 1
@@ -150,7 +157,7 @@ def __generate_single_cf(query_instance, desired_class, adjacency_matrix, causal
150
157
  else:
151
158
  raise ValueError("Unexpected format for cf")
152
159
 
153
- if is_unique_point(cf_dict):
160
+ if is_unique_point(cf_dict, bounds):
154
161
  sampled_trials += 1
155
162
  study.enqueue_trial(cf_dict)
156
163
  return sampled_trials
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: acfx
3
- Version: 0.3.6.dev4
3
+ Version: 0.3.7.dev1
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.6dev4"
7
+ version = "0.3.7dev1"
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