upgini 1.1.281__py3-none-any.whl → 1.1.282a3418.post1__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 upgini might be problematic. Click here for more details.
- upgini/__about__.py +1 -1
- upgini/autofe/all_operands.py +2 -1
- upgini/autofe/date.py +86 -2
- upgini/autofe/feature.py +16 -4
- upgini/autofe/operand.py +4 -2
- {upgini-1.1.281.dist-info → upgini-1.1.282a3418.post1.dist-info}/METADATA +1 -1
- {upgini-1.1.281.dist-info → upgini-1.1.282a3418.post1.dist-info}/RECORD +9 -9
- {upgini-1.1.281.dist-info → upgini-1.1.282a3418.post1.dist-info}/WHEEL +0 -0
- {upgini-1.1.281.dist-info → upgini-1.1.282a3418.post1.dist-info}/licenses/LICENSE +0 -0
upgini/__about__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.1.
|
|
1
|
+
__version__ = "1.1.282a3418-1"
|
upgini/autofe/all_operands.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Dict
|
|
2
2
|
|
|
3
3
|
from upgini.autofe.binary import Add, Divide, Max, Min, Multiply, Sim, Subtract
|
|
4
|
-
from upgini.autofe.date import DateDiff, DateDiffType2, DateListDiff, DateListDiffBounded
|
|
4
|
+
from upgini.autofe.date import DateDiff, DateDiffType2, DateListDiff, DateListDiffBounded, DatePercentile
|
|
5
5
|
from upgini.autofe.groupby import GroupByThenAgg, GroupByThenRank
|
|
6
6
|
from upgini.autofe.operand import Operand
|
|
7
7
|
from upgini.autofe.unary import Abs, Floor, Freq, Log, Residual, Sigmoid, Sqrt, Square
|
|
@@ -49,6 +49,7 @@ ALL_OPERANDS: Dict[str, Operand] = {
|
|
|
49
49
|
DateListDiffBounded(diff_unit="Y", aggregation="count", lower_bound=30, upper_bound=45),
|
|
50
50
|
DateListDiffBounded(diff_unit="Y", aggregation="count", lower_bound=45, upper_bound=60),
|
|
51
51
|
DateListDiffBounded(diff_unit="Y", aggregation="count", lower_bound=60),
|
|
52
|
+
DatePercentile(),
|
|
52
53
|
]
|
|
53
54
|
}
|
|
54
55
|
|
upgini/autofe/date.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
from
|
|
1
|
+
from datetime import date
|
|
2
|
+
from typing import Any, Dict, List, Optional, Union
|
|
2
3
|
|
|
3
4
|
import numpy as np
|
|
4
5
|
import pandas as pd
|
|
5
6
|
from pandas.core.arrays.timedeltas import TimedeltaArray
|
|
6
|
-
from pydantic import BaseModel
|
|
7
|
+
from pydantic import BaseModel, validator
|
|
7
8
|
|
|
8
9
|
from upgini.autofe.operand import PandasOperand
|
|
9
10
|
|
|
@@ -27,6 +28,17 @@ class DateDiff(PandasOperand, DateDiffMixin):
|
|
|
27
28
|
is_binary = True
|
|
28
29
|
has_symmetry_importance = True
|
|
29
30
|
|
|
31
|
+
def get_params(self) -> Dict[str, Optional[str]]:
|
|
32
|
+
res = super().get_params()
|
|
33
|
+
res.update(
|
|
34
|
+
{
|
|
35
|
+
"diff_unit": self.diff_unit,
|
|
36
|
+
"left_unit": self.left_unit,
|
|
37
|
+
"right_unit": self.right_unit,
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
return res
|
|
41
|
+
|
|
30
42
|
def calculate_binary(self, left: pd.Series, right: pd.Series) -> pd.Series:
|
|
31
43
|
left = self._convert_to_date(left, self.left_unit)
|
|
32
44
|
right = self._convert_to_date(right, self.right_unit)
|
|
@@ -42,6 +54,17 @@ class DateDiffType2(PandasOperand, DateDiffMixin):
|
|
|
42
54
|
is_binary = True
|
|
43
55
|
has_symmetry_importance = True
|
|
44
56
|
|
|
57
|
+
def get_params(self) -> Dict[str, Optional[str]]:
|
|
58
|
+
res = super().get_params()
|
|
59
|
+
res.update(
|
|
60
|
+
{
|
|
61
|
+
"diff_unit": self.diff_unit,
|
|
62
|
+
"left_unit": self.left_unit,
|
|
63
|
+
"right_unit": self.right_unit,
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
return res
|
|
67
|
+
|
|
45
68
|
def calculate_binary(self, left: pd.Series, right: pd.Series) -> pd.Series:
|
|
46
69
|
left = self._convert_to_date(left, self.left_unit)
|
|
47
70
|
right = self._convert_to_date(right, self.right_unit)
|
|
@@ -64,6 +87,15 @@ class DateListDiff(PandasOperand, DateDiffMixin):
|
|
|
64
87
|
has_symmetry_importance = True
|
|
65
88
|
aggregation: str
|
|
66
89
|
|
|
90
|
+
def get_params(self) -> Dict[str, Optional[str]]:
|
|
91
|
+
res = super().get_params()
|
|
92
|
+
res.update(
|
|
93
|
+
{
|
|
94
|
+
"aggregation": self.aggregation,
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
return res
|
|
98
|
+
|
|
67
99
|
def __init__(self, **data: Any) -> None:
|
|
68
100
|
if "name" not in data:
|
|
69
101
|
data["name"] = f"date_diff_{data.get('aggregation')}"
|
|
@@ -116,3 +148,55 @@ class DateListDiffBounded(DateListDiff):
|
|
|
116
148
|
def _agg(self, x):
|
|
117
149
|
x = x[(x >= (self.lower_bound or -np.inf)) & (x < (self.upper_bound or np.inf))]
|
|
118
150
|
return super()._agg(x)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class DatePercentile(PandasOperand):
|
|
154
|
+
name = "date_per"
|
|
155
|
+
is_binary = True
|
|
156
|
+
output_type = "float"
|
|
157
|
+
|
|
158
|
+
date_unit: Optional[str] = None
|
|
159
|
+
zero_month: Optional[int]
|
|
160
|
+
zero_year: Optional[int]
|
|
161
|
+
zero_bounds: Optional[List[float]]
|
|
162
|
+
step: int = 30
|
|
163
|
+
|
|
164
|
+
def get_params(self) -> Dict[str, Optional[str]]:
|
|
165
|
+
res = super().get_params()
|
|
166
|
+
res.update(
|
|
167
|
+
{
|
|
168
|
+
"date_unit": self.date_unit,
|
|
169
|
+
"zero_month": self.zero_month,
|
|
170
|
+
"zero_year": self.zero_year,
|
|
171
|
+
"zero_bounds": self.zero_bounds,
|
|
172
|
+
"step": self.step,
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
return res
|
|
176
|
+
|
|
177
|
+
@validator("zero_bounds", pre=True)
|
|
178
|
+
def validate_bounds(cls, value):
|
|
179
|
+
if value is None or isinstance(value, list):
|
|
180
|
+
return value
|
|
181
|
+
elif isinstance(value, str):
|
|
182
|
+
return value[1:-1].split(", ")
|
|
183
|
+
|
|
184
|
+
def calculate_binary(self, left: pd.Series, right: pd.Series) -> pd.Series:
|
|
185
|
+
# Assuming that left is a date column, right is a feature column
|
|
186
|
+
left = pd.to_datetime(left, unit=self.date_unit)
|
|
187
|
+
months = left.dt.month
|
|
188
|
+
years = left.dt.year
|
|
189
|
+
|
|
190
|
+
month_diffs = 12 * (years - (self.zero_year or 0)) + (months - (self.zero_month or 0))
|
|
191
|
+
bounds = month_diffs.apply(
|
|
192
|
+
lambda d: np.array(self.zero_bounds if self.zero_bounds is not None else []) + d * 30
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
return right.index.to_series().apply(lambda i: self.__perc(right[i], bounds[i]))
|
|
196
|
+
|
|
197
|
+
def __perc(self, f, bounds):
|
|
198
|
+
hit = np.where(f >= bounds)[0]
|
|
199
|
+
if hit.size > 0:
|
|
200
|
+
return np.max(hit) * 10
|
|
201
|
+
else:
|
|
202
|
+
return np.nan
|
upgini/autofe/feature.py
CHANGED
|
@@ -16,6 +16,12 @@ class Column:
|
|
|
16
16
|
self.data = data
|
|
17
17
|
self.calculate_all = calculate_all
|
|
18
18
|
|
|
19
|
+
def get_display_name(self, cache: bool = True, shorten: bool = False, **kwargs) -> str:
|
|
20
|
+
return self.name
|
|
21
|
+
|
|
22
|
+
def set_op_params(self, params: Dict[str, str]) -> "Column":
|
|
23
|
+
return self
|
|
24
|
+
|
|
19
25
|
def rename_columns(self, mapping: Dict[str, str]) -> "Column":
|
|
20
26
|
self.name = self._unhash(mapping.get(self.name) or self.name)
|
|
21
27
|
return self
|
|
@@ -69,14 +75,20 @@ class Feature:
|
|
|
69
75
|
self.cached_display_name = cached_display_name
|
|
70
76
|
self.alias = alias
|
|
71
77
|
|
|
72
|
-
def set_op_params(self, params: Dict[str, str]) -> "Feature":
|
|
78
|
+
def set_op_params(self, params: Optional[Dict[str, str]]) -> "Feature":
|
|
79
|
+
obj_dict = self.op.dict().copy()
|
|
80
|
+
obj_dict.update(params or {})
|
|
81
|
+
self.op = self.op.__class__.parse_obj(obj_dict)
|
|
73
82
|
self.op.set_params(params)
|
|
83
|
+
|
|
84
|
+
for child in self.children:
|
|
85
|
+
child.set_op_params(params)
|
|
74
86
|
return self
|
|
75
87
|
|
|
76
88
|
def get_hash(self) -> str:
|
|
77
|
-
return hashlib.sha256(
|
|
78
|
-
|
|
79
|
-
]
|
|
89
|
+
return hashlib.sha256(
|
|
90
|
+
"_".join([self.op.name] + [ch.get_display_name() for ch in self.children]).encode("utf-8")
|
|
91
|
+
).hexdigest()[:8]
|
|
80
92
|
|
|
81
93
|
def set_alias(self, alias: str) -> "Feature":
|
|
82
94
|
self.alias = alias
|
upgini/autofe/operand.py
CHANGED
|
@@ -25,8 +25,10 @@ class Operand(BaseModel):
|
|
|
25
25
|
self.params = params
|
|
26
26
|
return self
|
|
27
27
|
|
|
28
|
-
def get_params(self) -> Dict[str, str]:
|
|
29
|
-
|
|
28
|
+
def get_params(self) -> Dict[str, Optional[str]]:
|
|
29
|
+
res = {"alias": self.alias}
|
|
30
|
+
res.update(self.params or {})
|
|
31
|
+
return res
|
|
30
32
|
|
|
31
33
|
|
|
32
34
|
MAIN_COLUMN = "main_column"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
upgini/__about__.py,sha256=
|
|
1
|
+
upgini/__about__.py,sha256=GG1GC75bod-mGb53WjhL__a8G9_p00TZYiKG5snDjHQ,31
|
|
2
2
|
upgini/__init__.py,sha256=asENHgEVHQBIkV-e_0IhE_ZWqkCG6398U3ZLrNzAH6k,407
|
|
3
3
|
upgini/ads.py,sha256=nvuRxRx5MHDMgPr9SiU-fsqRdFaBv8p4_v1oqiysKpc,2714
|
|
4
4
|
upgini/dataset.py,sha256=7TLVVhGtjgx_9yaiaIUK3kZSe_R9wg5dY0d4F5qCGM4,45636
|
|
@@ -13,12 +13,12 @@ upgini/version_validator.py,sha256=RGg87VweujTNlibgsOuqPLIEiBgIOkuXNVTGuNCD234,1
|
|
|
13
13
|
upgini/ads_management/__init__.py,sha256=qzyisOToVRP-tquAJD1PblZhNtMrOB8FiyF9JvfkvgE,50
|
|
14
14
|
upgini/ads_management/ads_manager.py,sha256=igVbN2jz80Umb2BUJixmJVj-zx8unoKpecVo-R-nGdw,2648
|
|
15
15
|
upgini/autofe/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
-
upgini/autofe/all_operands.py,sha256=
|
|
16
|
+
upgini/autofe/all_operands.py,sha256=7UyvmmqGSqQu4kDgoFwQRKY__b9xKDk3Fpp2-H8A7AA,2399
|
|
17
17
|
upgini/autofe/binary.py,sha256=441BRuqMsxlxuw4c8rMZB6h5EpRdVMk-bVa03U7T5Hg,3973
|
|
18
|
-
upgini/autofe/date.py,sha256=
|
|
19
|
-
upgini/autofe/feature.py,sha256=
|
|
18
|
+
upgini/autofe/date.py,sha256=XeTJIkPzauYXgI3n5E8h4353PhZRZ7LOpQGHA4DMPx4,6758
|
|
19
|
+
upgini/autofe/feature.py,sha256=x7sumlIZqSE020XAkoykaesUjmmdYhaa0iFPKxBuDXo,12285
|
|
20
20
|
upgini/autofe/groupby.py,sha256=4WjDzQxqpZxB79Ih4ihMMI5GDxaFqiH6ZelfV82ClT4,3091
|
|
21
|
-
upgini/autofe/operand.py,sha256=
|
|
21
|
+
upgini/autofe/operand.py,sha256=JjEVT1U3kY9NDjUPMdoki7Oa8hMDG0-_h_NklVjIFyc,2882
|
|
22
22
|
upgini/autofe/unary.py,sha256=v-l3aiE5hj6kurvh6adCQL8W3X9u9a7RVbS_WPR2qlw,3146
|
|
23
23
|
upgini/autofe/vector.py,sha256=dLxfAstJs-gw_OQ1xxoxcM6pVzORlV0HVzdzt7cLXVQ,606
|
|
24
24
|
upgini/data_source/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -56,7 +56,7 @@ upgini/utils/sklearn_ext.py,sha256=c23MGSUVfxLnaDWKAxavHgnOtm5dGKkF3YswdWQcFzs,4
|
|
|
56
56
|
upgini/utils/target_utils.py,sha256=Y96_PJ5cC-WsEbeqg20v9uqywDQobLoTb-xoP7S3o4E,7807
|
|
57
57
|
upgini/utils/track_info.py,sha256=G5Lu1xxakg2_TQjKZk4b5SvrHsATTXNVV3NbvWtT8k8,5663
|
|
58
58
|
upgini/utils/warning_counter.py,sha256=dIWBB4dI5XRRJZudvIlqlIYKEiwLLPcXarsZuYRt338,227
|
|
59
|
-
upgini-1.1.
|
|
60
|
-
upgini-1.1.
|
|
61
|
-
upgini-1.1.
|
|
62
|
-
upgini-1.1.
|
|
59
|
+
upgini-1.1.282a3418.post1.dist-info/METADATA,sha256=XEY5jBcIoE7tG5ivbqU_75frPJwXZeMViN7fKn5wBv0,48129
|
|
60
|
+
upgini-1.1.282a3418.post1.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
|
|
61
|
+
upgini-1.1.282a3418.post1.dist-info/licenses/LICENSE,sha256=5RRzgvdJUu3BUDfv4bzVU6FqKgwHlIay63pPCSmSgzw,1514
|
|
62
|
+
upgini-1.1.282a3418.post1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|