psyke 0.8.6.dev2__tar.gz → 0.8.9__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.
Potentially problematic release.
This version of psyke might be problematic. Click here for more details.
- {psyke-0.8.6.dev2/psyke.egg-info → psyke-0.8.9}/PKG-INFO +1 -1
- psyke-0.8.9/VERSION +1 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/__init__.py +7 -6
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/cart/__init__.py +33 -15
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/cart/predictor.py +15 -5
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/hypercubic/iter/__init__.py +8 -2
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/schema/__init__.py +171 -14
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/tuning/pedro/__init__.py +4 -3
- {psyke-0.8.6.dev2 → psyke-0.8.9/psyke.egg-info}/PKG-INFO +1 -1
- psyke-0.8.6.dev2/VERSION +0 -1
- {psyke-0.8.6.dev2 → psyke-0.8.9}/LICENSE +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/MANIFEST.in +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/README.md +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/clustering/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/clustering/cream/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/clustering/exact/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/clustering/utils.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/hypercubic/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/hypercubic/cosmik/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/hypercubic/creepy/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/hypercubic/divine/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/hypercubic/gridex/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/hypercubic/gridrex/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/hypercubic/hex/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/hypercubic/hypercube.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/hypercubic/strategy.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/hypercubic/utils.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/real/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/real/utils.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/trepan/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/extraction/trepan/utils.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/hypercubepredictor.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/tuning/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/tuning/crash/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/tuning/orchid/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/utils/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/utils/dataframe.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/utils/logic.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/utils/metrics.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/utils/plot.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke/utils/sorted.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke.egg-info/SOURCES.txt +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke.egg-info/dependency_links.txt +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke.egg-info/not-zip-safe +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke.egg-info/requires.txt +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/psyke.egg-info/top_level.txt +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/pyproject.toml +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/setup.cfg +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/setup.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/clustering/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/cart/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/cart/test_cart.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/cart/test_simplified_cart.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/hypercubic/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/hypercubic/gridex/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/hypercubic/gridex/test_gridex.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/hypercubic/iter/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/hypercubic/iter/test_iter.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/hypercubic/test_hypercube.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/real/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/real/test_real.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/real/test_rule.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/trepan/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/trepan/test_node.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/trepan/test_split.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/extraction/trepan/test_trepan.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/utils/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/utils/test_prune.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/utils/test_simplify.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/psyke/utils/test_simplify_formatter.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/resources/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/resources/datasets/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/resources/predictors/__init__.py +0 -0
- {psyke-0.8.6.dev2 → psyke-0.8.9}/test/resources/tests/__init__.py +0 -0
psyke-0.8.9/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.8.9
|
|
@@ -256,14 +256,14 @@ class Extractor(EvaluableModel, ABC):
|
|
|
256
256
|
[Extractor.ClassificationScore.F1])[Extractor.ClassificationScore.F1][-1]
|
|
257
257
|
|
|
258
258
|
@staticmethod
|
|
259
|
-
def cart(predictor, max_depth: int = 3, max_leaves: int = 3,
|
|
259
|
+
def cart(predictor, max_depth: int = 3, max_leaves: int = 3, max_features=None,
|
|
260
260
|
discretization: Iterable[DiscreteFeature] = None, normalization=None, simplify: bool = True) -> Extractor:
|
|
261
261
|
"""
|
|
262
262
|
Creates a new Cart extractor.
|
|
263
263
|
"""
|
|
264
264
|
from psyke.extraction.cart import Cart
|
|
265
|
-
return Cart(predictor, max_depth, max_leaves,
|
|
266
|
-
simplify=simplify)
|
|
265
|
+
return Cart(predictor, max_depth, max_leaves, max_features,
|
|
266
|
+
discretization=discretization, normalization=normalization, simplify=simplify)
|
|
267
267
|
|
|
268
268
|
@staticmethod
|
|
269
269
|
def divine(predictor, k: int = 5, patience: int = 15, close_to_center: bool = True,
|
|
@@ -289,14 +289,15 @@ class Extractor(EvaluableModel, ABC):
|
|
|
289
289
|
|
|
290
290
|
@staticmethod
|
|
291
291
|
def iter(predictor, min_update: float = 0.1, n_points: int = 1, max_iterations: int = 600, min_examples: int = 250,
|
|
292
|
-
threshold: float = 0.1, fill_gaps: bool = True,
|
|
293
|
-
|
|
292
|
+
threshold: float = 0.1, fill_gaps: bool = True, ignore_dimensions=None,
|
|
293
|
+
normalization: dict[str, tuple[float, float]] = None, output=None,
|
|
294
|
+
seed: int = get_default_random_seed()) -> Extractor:
|
|
294
295
|
"""
|
|
295
296
|
Creates a new ITER extractor.
|
|
296
297
|
"""
|
|
297
298
|
from psyke.extraction.hypercubic.iter import ITER
|
|
298
299
|
return ITER(predictor, min_update, n_points, max_iterations, min_examples, threshold, fill_gaps,
|
|
299
|
-
normalization, output, seed)
|
|
300
|
+
ignore_dimensions, normalization, output, seed)
|
|
300
301
|
|
|
301
302
|
@staticmethod
|
|
302
303
|
def gridex(predictor, grid, min_examples: int = 250, threshold: float = 0.1, output: Target = Target.CONSTANT,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from abc import ABC
|
|
2
|
+
|
|
1
3
|
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
|
|
2
4
|
|
|
3
5
|
from psyke.extraction import PedagogicalExtractor
|
|
@@ -14,26 +16,28 @@ import pandas as pd
|
|
|
14
16
|
TREE_SEED = get_default_random_seed()
|
|
15
17
|
|
|
16
18
|
|
|
17
|
-
class Cart(PedagogicalExtractor):
|
|
19
|
+
class Cart(PedagogicalExtractor, ABC):
|
|
18
20
|
|
|
19
|
-
def __init__(self, predictor, max_depth: int = 3, max_leaves: int = None,
|
|
21
|
+
def __init__(self, predictor, max_depth: int = 3, max_leaves: int = None, max_features=None,
|
|
20
22
|
discretization: Iterable[DiscreteFeature] = None,
|
|
21
23
|
normalization=None, simplify: bool = True):
|
|
22
24
|
super().__init__(predictor, discretization, normalization)
|
|
23
25
|
self._cart_predictor = CartPredictor(normalization=normalization)
|
|
24
26
|
self.depth = max_depth
|
|
25
27
|
self.leaves = max_leaves
|
|
28
|
+
self.max_features = max_features
|
|
26
29
|
self._simplify = simplify
|
|
27
30
|
|
|
28
|
-
def _create_body(self, variables: dict[str, Var],
|
|
31
|
+
def _create_body(self, variables: dict[str, Var], conditions: LeafConstraints) -> Iterable[Struct]:
|
|
29
32
|
results = []
|
|
30
|
-
for feature_name,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
for feature_name, cond_list in conditions.items():
|
|
34
|
+
for condition in cond_list:
|
|
35
|
+
features = [d for d in self.discretization if feature_name in d.admissible_values]
|
|
36
|
+
feature: DiscreteFeature = features[0] if len(features) > 0 else None
|
|
37
|
+
results.append(create_term(variables[feature_name], condition) if feature is None else
|
|
38
|
+
create_term(variables[feature.name],
|
|
39
|
+
feature.admissible_values[feature_name],
|
|
40
|
+
isinstance(condition, GreaterThan)))
|
|
37
41
|
return results
|
|
38
42
|
|
|
39
43
|
@staticmethod
|
|
@@ -41,11 +45,12 @@ class Cart(PedagogicalExtractor):
|
|
|
41
45
|
simplified = [nodes.pop(0)]
|
|
42
46
|
while len(nodes) > 0:
|
|
43
47
|
first_node = nodes[0][0]
|
|
44
|
-
for
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
for k, conditions in first_node.items():
|
|
49
|
+
for condition in conditions:
|
|
50
|
+
if all(k in node[0] and condition in node[0][k] for node in nodes):
|
|
51
|
+
[node[0][k].remove(condition) for node in nodes]
|
|
47
52
|
simplified.append(nodes.pop(0))
|
|
48
|
-
return simplified
|
|
53
|
+
return [({k: v for k, v in rule.items() if v != []}, prediction) for rule, prediction in simplified]
|
|
49
54
|
|
|
50
55
|
def _create_theory(self, data: pd.DataFrame) -> Theory:
|
|
51
56
|
new_theory = mutable_theory()
|
|
@@ -66,13 +71,26 @@ class Cart(PedagogicalExtractor):
|
|
|
66
71
|
|
|
67
72
|
def _extract(self, data: pd.DataFrame) -> Theory:
|
|
68
73
|
tree = DecisionTreeClassifier if isinstance(data.iloc[0, -1], str) else DecisionTreeRegressor
|
|
69
|
-
self._cart_predictor.predictor = tree(random_state=TREE_SEED, max_depth=self.depth,
|
|
74
|
+
self._cart_predictor.predictor = tree(random_state=TREE_SEED, max_depth=self.depth,
|
|
75
|
+
max_leaf_nodes=self.leaves, max_features=self.max_features)
|
|
70
76
|
self._cart_predictor.predictor.fit(data.iloc[:, :-1], data.iloc[:, -1])
|
|
71
77
|
return self._create_theory(data)
|
|
72
78
|
|
|
73
79
|
def _predict(self, dataframe: pd.DataFrame) -> Iterable:
|
|
74
80
|
return self._cart_predictor.predict(dataframe)
|
|
75
81
|
|
|
82
|
+
def predict_why(self, data: dict[str, float], verbose=True):
|
|
83
|
+
prediction = None
|
|
84
|
+
conditions = {}
|
|
85
|
+
if self.normalization is not None:
|
|
86
|
+
data = {k: v * self.normalization[k][1] + self.normalization[k][0] if k in self.normalization else v
|
|
87
|
+
for k, v in data.items()}
|
|
88
|
+
for conditions, prediction in self._cart_predictor:
|
|
89
|
+
if all(all(interval.is_in(data[variable]) for interval in intervals)
|
|
90
|
+
for variable, intervals in conditions.items()):
|
|
91
|
+
break
|
|
92
|
+
return prediction, conditions
|
|
93
|
+
|
|
76
94
|
@property
|
|
77
95
|
def n_rules(self) -> int:
|
|
78
96
|
return self._cart_predictor.n_leaves
|
|
@@ -2,9 +2,9 @@ from collections import Iterable
|
|
|
2
2
|
from typing import Union, Any
|
|
3
3
|
import numpy as np
|
|
4
4
|
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
|
|
5
|
-
from psyke.schema import Value, LessThan, GreaterThan
|
|
5
|
+
from psyke.schema import Value, LessThan, GreaterThan, SchemaException
|
|
6
6
|
|
|
7
|
-
LeafConstraints =
|
|
7
|
+
LeafConstraints = dict[str, list[Value]]
|
|
8
8
|
LeafSequence = Iterable[tuple[LeafConstraints, Any]]
|
|
9
9
|
|
|
10
10
|
|
|
@@ -25,8 +25,17 @@ class CartPredictor:
|
|
|
25
25
|
if self.normalization is not None:
|
|
26
26
|
thresholds = [threshold * self.normalization[feature][1] + self.normalization[feature][0]
|
|
27
27
|
for feature, threshold in zip(features, thresholds)]
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
cond_dict = {}
|
|
29
|
+
for feature, condition, threshold in zip(features, conditions, thresholds):
|
|
30
|
+
cond = LessThan(threshold) if condition else GreaterThan(threshold)
|
|
31
|
+
if feature in cond_dict:
|
|
32
|
+
try:
|
|
33
|
+
cond_dict[feature][-1] *= cond
|
|
34
|
+
except SchemaException:
|
|
35
|
+
cond_dict[feature].append(cond)
|
|
36
|
+
else:
|
|
37
|
+
cond_dict[feature] = [cond]
|
|
38
|
+
return cond_dict
|
|
30
39
|
|
|
31
40
|
def __get_leaves(self) -> Iterable[int]:
|
|
32
41
|
return [i for i, (left_child, right_child) in enumerate(zip(
|
|
@@ -39,7 +48,8 @@ class CartPredictor:
|
|
|
39
48
|
else:
|
|
40
49
|
return self._predictor.tree_.value[node]
|
|
41
50
|
|
|
42
|
-
def __path(self, node: int, path=
|
|
51
|
+
def __path(self, node: int, path=None) -> Iterable[(int, bool)]:
|
|
52
|
+
path = [] if path is None else path
|
|
43
53
|
if node == 0:
|
|
44
54
|
return path
|
|
45
55
|
father = list(self._left_children if node in self._left_children else self._right_children).index(node)
|
|
@@ -16,8 +16,9 @@ class ITER(HyperCubeExtractor):
|
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
def __init__(self, predictor, min_update, n_points, max_iterations, min_examples, threshold, fill_gaps,
|
|
19
|
-
normalization, output: Target = Target.CONSTANT,
|
|
20
|
-
|
|
19
|
+
ignore_dimensions: Iterable, normalization, output: Target = Target.CONSTANT,
|
|
20
|
+
seed=get_default_random_seed()):
|
|
21
|
+
super().__init__(predictor, output, normalization=normalization)
|
|
21
22
|
if output is Target.REGRESSION:
|
|
22
23
|
raise NotImplementedError
|
|
23
24
|
self.predictor = predictor
|
|
@@ -30,6 +31,7 @@ class ITER(HyperCubeExtractor):
|
|
|
30
31
|
self._output = Target.CLASSIFICATION if isinstance(predictor, ClassifierMixin) else \
|
|
31
32
|
output if output is not None else Target.CONSTANT
|
|
32
33
|
self.seed = seed
|
|
34
|
+
self.ignore_dimensions = ignore_dimensions if ignore_dimensions is not None else []
|
|
33
35
|
|
|
34
36
|
def _best_cube(self, dataframe: pd.DataFrame, cube: GenericCube, cubes: Iterable[Expansion]) -> Expansion | None:
|
|
35
37
|
expansions = []
|
|
@@ -74,6 +76,8 @@ class ITER(HyperCubeExtractor):
|
|
|
74
76
|
hypercubes: Iterable[GenericCube]) -> Iterable[Expansion]:
|
|
75
77
|
tmp_cubes = []
|
|
76
78
|
for feature in self._surrounding.dimensions.keys():
|
|
79
|
+
if feature in self.ignore_dimensions:
|
|
80
|
+
continue
|
|
77
81
|
limit = cube.check_limits(feature)
|
|
78
82
|
if limit == '*':
|
|
79
83
|
continue
|
|
@@ -132,6 +136,8 @@ class ITER(HyperCubeExtractor):
|
|
|
132
136
|
hypercubes = self._generate_starting_points(dataframe)
|
|
133
137
|
for hypercube in hypercubes:
|
|
134
138
|
hypercube.expand_all(min_updates, self._surrounding)
|
|
139
|
+
for d in self.ignore_dimensions:
|
|
140
|
+
hypercube[d] = self._surrounding[d]
|
|
135
141
|
self.n_points = self.n_points - 1
|
|
136
142
|
if not HyperCube.check_overlap(hypercubes, hypercubes):
|
|
137
143
|
break
|
|
@@ -3,14 +3,27 @@ import math
|
|
|
3
3
|
from typing import Callable
|
|
4
4
|
from psyke.utils import get_int_precision
|
|
5
5
|
|
|
6
|
+
|
|
7
|
+
class SchemaException(Exception):
|
|
8
|
+
|
|
9
|
+
def __init__(self, message: str):
|
|
10
|
+
super().__init__(message)
|
|
11
|
+
|
|
12
|
+
|
|
6
13
|
_EMPTY_INTERSECTION_EXCEPTION: Callable = lambda x, y: \
|
|
7
|
-
|
|
14
|
+
SchemaException(f"Empty intersection between two Value: {str(x)} and {str(y)}")
|
|
8
15
|
|
|
9
16
|
_NOT_IMPLEMENTED_INTERSECTION: Callable = lambda x, y: \
|
|
10
|
-
|
|
17
|
+
SchemaException(f"Not implemented intersection between: {str(x)} and {str(y)}")
|
|
11
18
|
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
_OPERATION_WITH_WRONG_TYPE: Callable = lambda x, y: \
|
|
20
|
+
SchemaException("Calling method with wrong type argument: " + str(x) + ' and ' + str(y))
|
|
21
|
+
|
|
22
|
+
_EMPTY_UNION_EXCEPTION: Callable = lambda x, y: \
|
|
23
|
+
SchemaException(f"Empty union between two Value: {str(x)} and {str(y)}")
|
|
24
|
+
|
|
25
|
+
_NOT_IMPLEMENTED_UNION: Callable = lambda x, y: \
|
|
26
|
+
SchemaException("Not implemented union between: " + str(x) + ' and ' + str(y))
|
|
14
27
|
|
|
15
28
|
PRECISION = get_int_precision()
|
|
16
29
|
STRING_PRECISION = str(PRECISION)
|
|
@@ -109,7 +122,7 @@ class Value:
|
|
|
109
122
|
else:
|
|
110
123
|
raise _EMPTY_INTERSECTION_EXCEPTION(first_value, second_value)
|
|
111
124
|
else:
|
|
112
|
-
raise
|
|
125
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
113
126
|
|
|
114
127
|
def intersection_with_outside(first_value: Outside, second_value: Value) -> Value:
|
|
115
128
|
if isinstance(first_value, Outside):
|
|
@@ -154,9 +167,9 @@ class Value:
|
|
|
154
167
|
elif isinstance(second_value, Constant):
|
|
155
168
|
return intersection_with_constant(second_value, first_value)
|
|
156
169
|
else:
|
|
157
|
-
raise
|
|
170
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
158
171
|
else:
|
|
159
|
-
raise
|
|
172
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
160
173
|
|
|
161
174
|
def intersection_with_between(first_value: Between, second_value: Value) -> Value:
|
|
162
175
|
if isinstance(first_value, Between):
|
|
@@ -194,9 +207,9 @@ class Value:
|
|
|
194
207
|
elif isinstance(second_value, Outside):
|
|
195
208
|
return intersection_with_outside(second_value, first_value)
|
|
196
209
|
else:
|
|
197
|
-
raise
|
|
210
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
198
211
|
else:
|
|
199
|
-
raise
|
|
212
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
200
213
|
|
|
201
214
|
def intersection_with_less_than(first_value: LessThan, second_value: Value) -> Value:
|
|
202
215
|
if isinstance(first_value, LessThan):
|
|
@@ -214,9 +227,9 @@ class Value:
|
|
|
214
227
|
elif isinstance(second_value, Between):
|
|
215
228
|
return intersection_with_between(second_value, first_value)
|
|
216
229
|
else:
|
|
217
|
-
raise
|
|
230
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
218
231
|
else:
|
|
219
|
-
raise
|
|
232
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
220
233
|
|
|
221
234
|
def intersection_with_greater_than(first_value: GreaterThan, second_value: Value) -> Value:
|
|
222
235
|
if isinstance(first_value, GreaterThan):
|
|
@@ -231,9 +244,9 @@ class Value:
|
|
|
231
244
|
elif isinstance(second_value, LessThan):
|
|
232
245
|
return intersection_with_less_than(second_value, first_value)
|
|
233
246
|
else:
|
|
234
|
-
raise
|
|
247
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
235
248
|
else:
|
|
236
|
-
raise
|
|
249
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
237
250
|
|
|
238
251
|
if other is None:
|
|
239
252
|
return self
|
|
@@ -248,7 +261,151 @@ class Value:
|
|
|
248
261
|
elif isinstance(self, GreaterThan):
|
|
249
262
|
return intersection_with_greater_than(self, other)
|
|
250
263
|
else:
|
|
251
|
-
raise
|
|
264
|
+
raise _OPERATION_WITH_WRONG_TYPE(self, other)
|
|
265
|
+
|
|
266
|
+
def __add__(self, other) -> Value:
|
|
267
|
+
|
|
268
|
+
def union_with_constant(first_value: Constant, second_value: Value) -> Value:
|
|
269
|
+
if isinstance(first_value, Constant):
|
|
270
|
+
if first_value in second_value:
|
|
271
|
+
return second_value
|
|
272
|
+
else:
|
|
273
|
+
raise _NOT_IMPLEMENTED_UNION(first_value, second_value)
|
|
274
|
+
else:
|
|
275
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
276
|
+
|
|
277
|
+
def union_with_outside(first_value: Outside, second_value: Value) -> Value:
|
|
278
|
+
if isinstance(first_value, Outside):
|
|
279
|
+
if isinstance(second_value, LessThan):
|
|
280
|
+
if second_value.value > first_value.upper:
|
|
281
|
+
return Between(-math.inf, math.inf)
|
|
282
|
+
elif second_value.value > first_value.lower:
|
|
283
|
+
return Outside(second_value.value, first_value.upper)
|
|
284
|
+
else:
|
|
285
|
+
return first_value
|
|
286
|
+
elif isinstance(second_value, GreaterThan):
|
|
287
|
+
if second_value.value < first_value.lower:
|
|
288
|
+
return Between(-math.inf, math.inf)
|
|
289
|
+
elif second_value.value < first_value.upper:
|
|
290
|
+
return Outside(first_value.lower, second_value.value)
|
|
291
|
+
else:
|
|
292
|
+
return first_value
|
|
293
|
+
elif isinstance(second_value, Between):
|
|
294
|
+
if second_value.upper <= first_value.lower or second_value.lower >= first_value.upper:
|
|
295
|
+
return first_value
|
|
296
|
+
elif second_value.lower <= first_value.lower <= second_value.upper <= first_value.upper:
|
|
297
|
+
return Outside(second_value.upper, first_value.lower)
|
|
298
|
+
elif first_value.lower <= second_value.lower <= first_value.upper <= second_value.upper:
|
|
299
|
+
return Outside(first_value.upper, second_value.lower)
|
|
300
|
+
elif second_value.lower <= first_value.lower <= first_value.upper <= second_value.upper:
|
|
301
|
+
return Between(-math.inf, math.inf)
|
|
302
|
+
else:
|
|
303
|
+
raise _NOT_IMPLEMENTED_UNION(first_value, second_value)
|
|
304
|
+
elif isinstance(second_value, Outside):
|
|
305
|
+
if second_value.lower <= first_value.lower <= first_value.upper <= second_value.upper:
|
|
306
|
+
return first_value
|
|
307
|
+
elif first_value.lower <= second_value.lower <= second_value.upper <= first_value.upper:
|
|
308
|
+
return second_value
|
|
309
|
+
elif second_value.lower <= first_value.lower <= second_value.upper <= first_value.upper:
|
|
310
|
+
return Outside(first_value.lower, second_value.upper)
|
|
311
|
+
elif first_value.lower <= second_value.lower <= first_value.upper <= second_value.upper:
|
|
312
|
+
return Outside(second_value.lower, first_value.upper)
|
|
313
|
+
else:
|
|
314
|
+
return Between(-math.inf, math.inf)
|
|
315
|
+
elif isinstance(second_value, Constant):
|
|
316
|
+
return union_with_constant(second_value, first_value)
|
|
317
|
+
else:
|
|
318
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
319
|
+
else:
|
|
320
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
321
|
+
|
|
322
|
+
def union_with_between(first_value: Between, second_value: Value) -> Value:
|
|
323
|
+
if isinstance(first_value, Between):
|
|
324
|
+
if isinstance(second_value, LessThan):
|
|
325
|
+
if second_value.value <= first_value.lower:
|
|
326
|
+
raise _NOT_IMPLEMENTED_UNION(first_value, second_value)
|
|
327
|
+
elif first_value.lower <= second_value.value <= first_value.upper:
|
|
328
|
+
return LessThan(first_value.upper)
|
|
329
|
+
else:
|
|
330
|
+
return second_value
|
|
331
|
+
elif isinstance(second_value, GreaterThan):
|
|
332
|
+
if second_value.value <= first_value.lower:
|
|
333
|
+
return second_value
|
|
334
|
+
elif first_value.lower <= second_value.value <= first_value.upper:
|
|
335
|
+
return GreaterThan(first_value.lower)
|
|
336
|
+
else:
|
|
337
|
+
raise _NOT_IMPLEMENTED_UNION(first_value, second_value)
|
|
338
|
+
elif isinstance(second_value, Between):
|
|
339
|
+
if second_value in first_value:
|
|
340
|
+
return first_value
|
|
341
|
+
elif first_value in second_value:
|
|
342
|
+
return second_value
|
|
343
|
+
elif first_value.lower <= second_value.lower <= first_value.upper:
|
|
344
|
+
return Between(first_value.lower, second_value.upper)
|
|
345
|
+
elif second_value.lower <= first_value.lower <= second_value.upper <= first_value.upper:
|
|
346
|
+
return Between(second_value.lower, first_value.upper)
|
|
347
|
+
else:
|
|
348
|
+
raise _NOT_IMPLEMENTED_UNION(first_value, second_value)
|
|
349
|
+
elif isinstance(second_value, Constant):
|
|
350
|
+
return union_with_constant(second_value, first_value)
|
|
351
|
+
elif isinstance(second_value, Outside):
|
|
352
|
+
return union_with_outside(second_value, first_value)
|
|
353
|
+
else:
|
|
354
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
355
|
+
else:
|
|
356
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
357
|
+
|
|
358
|
+
def union_with_less_than(first_value: LessThan, second_value: Value) -> Value:
|
|
359
|
+
if isinstance(first_value, LessThan):
|
|
360
|
+
if isinstance(second_value, LessThan):
|
|
361
|
+
return second_value if first_value in second_value else first_value
|
|
362
|
+
elif isinstance(second_value, GreaterThan):
|
|
363
|
+
if second_value.value <= first_value.value:
|
|
364
|
+
return Between(-math.inf, math.inf)
|
|
365
|
+
else:
|
|
366
|
+
return Outside(first_value.value, second_value.value)
|
|
367
|
+
elif isinstance(second_value, Constant):
|
|
368
|
+
return union_with_constant(second_value, first_value)
|
|
369
|
+
elif isinstance(second_value, Outside):
|
|
370
|
+
return union_with_outside(second_value, first_value)
|
|
371
|
+
elif isinstance(second_value, Between):
|
|
372
|
+
return union_with_between(second_value, first_value)
|
|
373
|
+
else:
|
|
374
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
375
|
+
else:
|
|
376
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
377
|
+
|
|
378
|
+
def union_with_greater_than(first_value: GreaterThan, second_value: Value) -> Value:
|
|
379
|
+
if isinstance(first_value, GreaterThan):
|
|
380
|
+
if isinstance(second_value, GreaterThan):
|
|
381
|
+
return second_value if first_value in second_value else first_value
|
|
382
|
+
elif isinstance(second_value, Constant):
|
|
383
|
+
return union_with_constant(second_value, first_value)
|
|
384
|
+
elif isinstance(second_value, Outside):
|
|
385
|
+
return union_with_outside(second_value, first_value)
|
|
386
|
+
elif isinstance(second_value, Between):
|
|
387
|
+
return union_with_between(second_value, first_value)
|
|
388
|
+
elif isinstance(second_value, LessThan):
|
|
389
|
+
return union_with_less_than(second_value, first_value)
|
|
390
|
+
else:
|
|
391
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
392
|
+
else:
|
|
393
|
+
raise _OPERATION_WITH_WRONG_TYPE(first_value, second_value)
|
|
394
|
+
|
|
395
|
+
if other is None:
|
|
396
|
+
return self
|
|
397
|
+
elif isinstance(self, Constant):
|
|
398
|
+
return union_with_constant(self, other)
|
|
399
|
+
elif isinstance(self, Outside):
|
|
400
|
+
return union_with_outside(self, other)
|
|
401
|
+
elif isinstance(self, Between):
|
|
402
|
+
return union_with_between(self, other)
|
|
403
|
+
elif isinstance(self, LessThan):
|
|
404
|
+
return union_with_less_than(self, other)
|
|
405
|
+
elif isinstance(self, GreaterThan):
|
|
406
|
+
return union_with_greater_than(self, other)
|
|
407
|
+
else:
|
|
408
|
+
raise _OPERATION_WITH_WRONG_TYPE(self, other)
|
|
252
409
|
|
|
253
410
|
def print(self) -> str:
|
|
254
411
|
pass
|
|
@@ -98,14 +98,15 @@ class PEDRO(SKEOptimizer, IterativeOptimizer):
|
|
|
98
98
|
return False
|
|
99
99
|
|
|
100
100
|
def search(self):
|
|
101
|
+
max_partitions = 200
|
|
101
102
|
base_partitions = FixedStrategy(2).partition_number(self.dataframe.columns[:-1]) * 3
|
|
102
|
-
if base_partitions <=
|
|
103
|
+
if base_partitions <= max_partitions:
|
|
103
104
|
strategies = [FixedStrategy(2)]
|
|
104
|
-
if FixedStrategy(3).partition_number(self.dataframe.columns[:-1]) <=
|
|
105
|
+
if FixedStrategy(3).partition_number(self.dataframe.columns[:-1]) <= max_partitions:
|
|
105
106
|
strategies.append(FixedStrategy(3))
|
|
106
107
|
else:
|
|
107
108
|
strategies = []
|
|
108
|
-
base_partitions =
|
|
109
|
+
base_partitions = max_partitions
|
|
109
110
|
|
|
110
111
|
for n in [2, 3, 5, 10]:
|
|
111
112
|
for th in [0.99, 0.75, 0.67, 0.5, 0.3]:
|
psyke-0.8.6.dev2/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.8.6.dev2
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|