psyke 0.8.2.dev8__py3-none-any.whl → 0.8.2.dev12__py3-none-any.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.
Potentially problematic release.
This version of psyke might be problematic. Click here for more details.
- psyke/extraction/hypercubic/__init__.py +40 -10
- {psyke-0.8.2.dev8.dist-info → psyke-0.8.2.dev12.dist-info}/METADATA +1 -1
- {psyke-0.8.2.dev8.dist-info → psyke-0.8.2.dev12.dist-info}/RECORD +6 -6
- {psyke-0.8.2.dev8.dist-info → psyke-0.8.2.dev12.dist-info}/LICENSE +0 -0
- {psyke-0.8.2.dev8.dist-info → psyke-0.8.2.dev12.dist-info}/WHEEL +0 -0
- {psyke-0.8.2.dev8.dist-info → psyke-0.8.2.dev12.dist-info}/top_level.txt +0 -0
|
@@ -44,38 +44,68 @@ class HyperCubeExtractor(HyperCubePredictor, PedagogicalExtractor, ABC):
|
|
|
44
44
|
self._surrounding.update(dataframe, self.predictor)
|
|
45
45
|
return theory
|
|
46
46
|
|
|
47
|
-
def
|
|
47
|
+
def pairwise_fairness(self, data: dict[str, float], neighbor: dict[str, float]):
|
|
48
|
+
cube1 = self._find_cube(data.copy())
|
|
49
|
+
cube2 = self._find_cube(neighbor.copy())
|
|
50
|
+
different_prediction_reasons = []
|
|
51
|
+
|
|
52
|
+
if cube1.output == cube2.output:
|
|
53
|
+
print("Prediction", cube1.output, "is FAIR")
|
|
54
|
+
else:
|
|
55
|
+
print("Prediction", cube1.output, "may be UNFAIR")
|
|
56
|
+
print("It could be", cube2.output, "if:")
|
|
57
|
+
for d in data:
|
|
58
|
+
a, b = cube2.dimensions[d]
|
|
59
|
+
if data[d] < a:
|
|
60
|
+
print(' ', d, 'increases above', round(a, 1))
|
|
61
|
+
different_prediction_reasons.append(d)
|
|
62
|
+
elif data[d] > b:
|
|
63
|
+
print(' ', d, 'decreases below', round(b, 1))
|
|
64
|
+
different_prediction_reasons.append(d)
|
|
65
|
+
return different_prediction_reasons
|
|
66
|
+
|
|
67
|
+
def predict_counter(self, data: dict[str, float], verbose=True):
|
|
68
|
+
output = ""
|
|
69
|
+
prediction = None
|
|
48
70
|
cube = self._find_cube(data.copy())
|
|
49
71
|
if cube is None:
|
|
50
|
-
|
|
72
|
+
output += "The extracted knowledge is not exhaustive; impossible to predict this instance"
|
|
51
73
|
else:
|
|
52
|
-
|
|
74
|
+
prediction = self._predict_from_cubes(data)
|
|
75
|
+
output += f"The output is {prediction}\n"
|
|
53
76
|
|
|
54
77
|
point = Point(list(data.keys()), list(data.values()))
|
|
55
78
|
cubes = self._hypercubes if cube is None else [c for c in self._hypercubes if cube.output != c.output]
|
|
56
79
|
cubes = sorted([(cube.surface_distance(point), cube.volume(), cube) for cube in cubes])
|
|
57
80
|
outputs = []
|
|
81
|
+
different_prediction_reasons = []
|
|
58
82
|
for _, _, c in cubes:
|
|
59
83
|
if c.output not in outputs:
|
|
60
84
|
outputs.append(c.output)
|
|
61
|
-
|
|
85
|
+
output += f"The output may be {c.output} if"
|
|
62
86
|
|
|
63
87
|
for d in point.dimensions.keys():
|
|
64
88
|
lower, upper = c[d]
|
|
65
89
|
p = point[d]
|
|
66
90
|
if p < lower:
|
|
67
|
-
|
|
91
|
+
output += f"\n {d} increases above {round(lower, 1)}"
|
|
92
|
+
different_prediction_reasons.append((d, '>=', lower))
|
|
68
93
|
elif p > upper:
|
|
69
|
-
|
|
94
|
+
output += f"\n {d} decreses below {round(upper, 1)}"
|
|
95
|
+
different_prediction_reasons.append((d, '<=', upper))
|
|
96
|
+
if verbose:
|
|
97
|
+
print(output)
|
|
98
|
+
return prediction, different_prediction_reasons
|
|
70
99
|
|
|
71
|
-
def __get_local_conditions(self, cube: GenericCube) -> dict[list[Value]]:
|
|
100
|
+
def __get_local_conditions(self, data: dict[str, float], cube: GenericCube) -> dict[list[Value]]:
|
|
72
101
|
conditions = {d: [] for d in cube.dimensions}
|
|
73
102
|
for d in cube.finite_dimensions:
|
|
74
103
|
conditions[d].append(Between(*cube.dimensions[d]))
|
|
75
104
|
subcubes = cube.subcubes(self._hypercubes)
|
|
76
105
|
for c in [c for c in subcubes if sum(c in sc and c != sc for sc in subcubes) == 0]:
|
|
77
|
-
for d in c.finite_dimensions:
|
|
78
|
-
|
|
106
|
+
for d in [d for d in c.finite_dimensions if d in data]:
|
|
107
|
+
if c.dimensions[d][0] > data[d] or c.dimensions[d][1] < data[d]:
|
|
108
|
+
conditions[d].append(Outside(*c.dimensions[d]))
|
|
79
109
|
return conditions
|
|
80
110
|
|
|
81
111
|
def predict_why(self, data: dict[str, float]):
|
|
@@ -85,7 +115,7 @@ class HyperCubeExtractor(HyperCubePredictor, PedagogicalExtractor, ABC):
|
|
|
85
115
|
else:
|
|
86
116
|
output = self._predict_from_cubes(data)
|
|
87
117
|
print(f"The output is {output} because")
|
|
88
|
-
conditions = self.__get_local_conditions(cube)
|
|
118
|
+
conditions = self.__get_local_conditions(data, cube)
|
|
89
119
|
for d in data.keys():
|
|
90
120
|
simplified = HyperCubeExtractor.__simplify(conditions[d])
|
|
91
121
|
for i, condition in enumerate(simplified):
|
|
@@ -7,7 +7,7 @@ psyke/clustering/exact/__init__.py,sha256=GpMGOcN2bGn3wfaUKOdis3vnLEtAx9j886qsk-
|
|
|
7
7
|
psyke/extraction/__init__.py,sha256=ziZ8T9eAOZjKipepE5_j1zfZgyFPONjW8MGERSk83nI,743
|
|
8
8
|
psyke/extraction/cart/__init__.py,sha256=s8tr7jPhONgF0pfetHieFax2MD8cy6ddOS7dRWzZLjc,3579
|
|
9
9
|
psyke/extraction/cart/predictor.py,sha256=2-2mv5fI0lTwwfTaEonxKh0ZUdhxuIEE6OP_rJxgmqc,3019
|
|
10
|
-
psyke/extraction/hypercubic/__init__.py,sha256=
|
|
10
|
+
psyke/extraction/hypercubic/__init__.py,sha256=2Y9C-bjwqFPlwRDv02sgZyyZv9-DGb8Sk4BHw9f_cVI,11842
|
|
11
11
|
psyke/extraction/hypercubic/hypercube.py,sha256=vYJoIEAsiIY5koh84hnSdd72PPc-7-RP_1Eo5vvjxk4,22754
|
|
12
12
|
psyke/extraction/hypercubic/strategy.py,sha256=X-roIsfcpJyMdo2px5JtbhP7-XE-zUNkaEK7XGXoWA8,1636
|
|
13
13
|
psyke/extraction/hypercubic/utils.py,sha256=D2FN5CCm_T3h23DmLFoTnIcFo7LvIq__ktl4hjUqkcA,1525
|
|
@@ -33,8 +33,8 @@ psyke/utils/logic.py,sha256=7bbW6qcKof5PlqoQ0n5Kt3Obcot-KqGAvpE8rMXvEPE,12419
|
|
|
33
33
|
psyke/utils/metrics.py,sha256=Oo5BOonOSfo0qYsXWT5dmypZ7jiStByFC2MKEU0uMHg,2250
|
|
34
34
|
psyke/utils/plot.py,sha256=dE8JJ6tQ0Ezosid-r2jqAisREjFe5LqExRzsVi5Ns-c,7785
|
|
35
35
|
psyke/utils/sorted.py,sha256=C3CPW2JisND30BRk5c1sAAHs3Lb_wsRB2qZrYFuRnfM,678
|
|
36
|
-
psyke-0.8.2.
|
|
37
|
-
psyke-0.8.2.
|
|
38
|
-
psyke-0.8.2.
|
|
39
|
-
psyke-0.8.2.
|
|
40
|
-
psyke-0.8.2.
|
|
36
|
+
psyke-0.8.2.dev12.dist-info/LICENSE,sha256=KP9K6Hgezf_xdMFW7ORyKz9uA8Y8k52YJn292wcP-_E,11354
|
|
37
|
+
psyke-0.8.2.dev12.dist-info/METADATA,sha256=kLYg_5PyZAEfsxMgoiPuvxkCogsbSRGACfeBHl_O9_I,8108
|
|
38
|
+
psyke-0.8.2.dev12.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
39
|
+
psyke-0.8.2.dev12.dist-info/top_level.txt,sha256=q1HglxOqqoIRukFtyis_ZNHczZg4gANRUPWkD7HAUTU,6
|
|
40
|
+
psyke-0.8.2.dev12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|