psyke 0.9.0__py3-none-any.whl → 0.9.0.dev1__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/trepan/__init__.py +17 -13
- {psyke-0.9.0.dist-info → psyke-0.9.0.dev1.dist-info}/METADATA +1 -1
- {psyke-0.9.0.dist-info → psyke-0.9.0.dev1.dist-info}/RECORD +6 -6
- {psyke-0.9.0.dist-info → psyke-0.9.0.dev1.dist-info}/WHEEL +0 -0
- {psyke-0.9.0.dist-info → psyke-0.9.0.dev1.dist-info}/licenses/LICENSE +0 -0
- {psyke-0.9.0.dist-info → psyke-0.9.0.dev1.dist-info}/top_level.txt +0 -0
|
@@ -15,11 +15,17 @@ class Trepan(PedagogicalExtractor):
|
|
|
15
15
|
def __init__(self, predictor, discretization: Iterable[DiscreteFeature], min_examples: int = 0, max_depth: int = 3,
|
|
16
16
|
split_logic: SplitLogic = SplitLogic.DEFAULT):
|
|
17
17
|
super().__init__(predictor, discretization)
|
|
18
|
+
self._ignore_feature = []
|
|
18
19
|
self.min_examples = min_examples
|
|
19
20
|
self.max_depth = max_depth
|
|
20
21
|
self.split_logic = split_logic
|
|
21
22
|
self._root: Node
|
|
22
23
|
|
|
24
|
+
def make_fair(self, features: Iterable[str]):
|
|
25
|
+
self._ignore_feature = [list(i.admissible_values.keys()) for i in self.discretization if i.name in features] \
|
|
26
|
+
if self.discretization else [features]
|
|
27
|
+
self._ignore_feature = [feature for features in self._ignore_feature for feature in features]
|
|
28
|
+
|
|
23
29
|
@property
|
|
24
30
|
def n_rules(self):
|
|
25
31
|
return sum(1 for _ in self._root)
|
|
@@ -29,7 +35,7 @@ class Trepan(PedagogicalExtractor):
|
|
|
29
35
|
raise NotImplementedError()
|
|
30
36
|
if node.n_classes == 1:
|
|
31
37
|
return None
|
|
32
|
-
splits =
|
|
38
|
+
splits = self._create_splits(node, names)
|
|
33
39
|
return None if len(splits) == 0 or splits[0].children[0].depth > self.max_depth else splits[0].children
|
|
34
40
|
|
|
35
41
|
def _compact(self):
|
|
@@ -55,22 +61,20 @@ class Trepan(PedagogicalExtractor):
|
|
|
55
61
|
def _create_split(node: Node, column: str) -> Union[Split, None]:
|
|
56
62
|
true_examples = Trepan._create_samples(node, column, 1.0)
|
|
57
63
|
false_examples = Trepan._create_samples(node, column, 0.0)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
true_node = Node(true_examples, node.n_examples,
|
|
64
|
+
true_constraints = list(node.constraints) + [(column, 1.0)]
|
|
65
|
+
false_constraints = list(node.constraints) + [(column, 0.0)]
|
|
66
|
+
true_node = Node(true_examples, node.n_examples, true_constraints, depth=node.depth + 1) \
|
|
61
67
|
if true_examples.shape[0] > 0 else None
|
|
62
|
-
false_node = Node(false_examples, node.n_examples,
|
|
68
|
+
false_node = Node(false_examples, node.n_examples, false_constraints, depth=node.depth + 1) \
|
|
63
69
|
if false_examples.shape[0] > 0 else None
|
|
64
70
|
return None if true_node is None or false_node is None else Split(node, (true_node, false_node))
|
|
65
71
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if
|
|
71
|
-
|
|
72
|
-
if split is not None:
|
|
73
|
-
splits.add(split)
|
|
72
|
+
def _create_splits(self, node: Node, names: Iterable[str]) -> SortedList[Split]:
|
|
73
|
+
splits, constraints = Trepan._init_splits(node)
|
|
74
|
+
for column in [column for column in names if column not in list(constraints) + self._ignore_feature]:
|
|
75
|
+
split = Trepan._create_split(node, column)
|
|
76
|
+
if split is not None:
|
|
77
|
+
splits.add(split)
|
|
74
78
|
return splits
|
|
75
79
|
|
|
76
80
|
def _create_theory(self, name: str) -> MutableTheory:
|
|
@@ -22,7 +22,7 @@ psyke/extraction/hypercubic/hex/__init__.py,sha256=553AZjOT9thfqDGtVDI6WtgYNex2Y
|
|
|
22
22
|
psyke/extraction/hypercubic/iter/__init__.py,sha256=bb0neiPcNlyyr-OUUjgw4vdkehnAsoyJzVJ88jAHtQ8,10233
|
|
23
23
|
psyke/extraction/real/__init__.py,sha256=t3wrY4dEmZK3PhGexxHh1bhlCr4vvZ1IS6vDZoHyZjw,5379
|
|
24
24
|
psyke/extraction/real/utils.py,sha256=4NNL15Eu7cmkG9b29GBP6CKgMTV1cmiJVS0k1MbWpIs,2148
|
|
25
|
-
psyke/extraction/trepan/__init__.py,sha256=
|
|
25
|
+
psyke/extraction/trepan/__init__.py,sha256=H8F_wpFLPcfyx2tgOOno8FwUomxfVxVl1vxlb0ClP1g,6931
|
|
26
26
|
psyke/extraction/trepan/utils.py,sha256=iSUJ1ooNQT_VO1KfBZuIUeUsyUbGdQf_pSEE87vMeQg,2320
|
|
27
27
|
psyke/schema/__init__.py,sha256=axv4ejZY0ItUwrC9IXb_yAhaQL5f1vwvXXmaIAHJmt0,26063
|
|
28
28
|
psyke/tuning/__init__.py,sha256=yd_ForFmHeYbtRXltY1fOa-mPJvpE6ijzg50M_8Sdxw,3649
|
|
@@ -35,8 +35,8 @@ psyke/utils/logic.py,sha256=ioP25WMTYNYEzaRDNDe3kGNWqZ6DA_63t19d-ky_2kM,12227
|
|
|
35
35
|
psyke/utils/metrics.py,sha256=Oo5BOonOSfo0qYsXWT5dmypZ7jiStByFC2MKEU0uMHg,2250
|
|
36
36
|
psyke/utils/plot.py,sha256=dE8JJ6tQ0Ezosid-r2jqAisREjFe5LqExRzsVi5Ns-c,7785
|
|
37
37
|
psyke/utils/sorted.py,sha256=C3CPW2JisND30BRk5c1sAAHs3Lb_wsRB2qZrYFuRnfM,678
|
|
38
|
-
psyke-0.9.0.dist-info/licenses/LICENSE,sha256=KP9K6Hgezf_xdMFW7ORyKz9uA8Y8k52YJn292wcP-_E,11354
|
|
39
|
-
psyke-0.9.0.dist-info/METADATA,sha256=
|
|
40
|
-
psyke-0.9.0.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
41
|
-
psyke-0.9.0.dist-info/top_level.txt,sha256=q1HglxOqqoIRukFtyis_ZNHczZg4gANRUPWkD7HAUTU,6
|
|
42
|
-
psyke-0.9.0.dist-info/RECORD,,
|
|
38
|
+
psyke-0.9.0.dev1.dist-info/licenses/LICENSE,sha256=KP9K6Hgezf_xdMFW7ORyKz9uA8Y8k52YJn292wcP-_E,11354
|
|
39
|
+
psyke-0.9.0.dev1.dist-info/METADATA,sha256=YQQ4BWoNe-23RnTWikpxeITjxypGFYQC6pWZmVd1XDA,8394
|
|
40
|
+
psyke-0.9.0.dev1.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
41
|
+
psyke-0.9.0.dev1.dist-info/top_level.txt,sha256=q1HglxOqqoIRukFtyis_ZNHczZg4gANRUPWkD7HAUTU,6
|
|
42
|
+
psyke-0.9.0.dev1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|