upgini 1.1.284__py3-none-any.whl → 1.1.285a3418.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 +85 -2
- upgini/autofe/feature.py +22 -5
- upgini/autofe/operand.py +4 -2
- upgini/features_enricher.py +13 -10
- upgini/metadata.py +3 -1
- {upgini-1.1.284.dist-info → upgini-1.1.285a3418.post1.dist-info}/METADATA +1 -1
- {upgini-1.1.284.dist-info → upgini-1.1.285a3418.post1.dist-info}/RECORD +11 -11
- {upgini-1.1.284.dist-info → upgini-1.1.285a3418.post1.dist-info}/WHEEL +0 -0
- {upgini-1.1.284.dist-info → upgini-1.1.285a3418.post1.dist-info}/licenses/LICENSE +0 -0
upgini/__about__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.1.
|
|
1
|
+
__version__ = "1.1.285a3418-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,9 @@
|
|
|
1
|
-
from typing import Any, Optional, Union
|
|
1
|
+
from typing import Any, Dict, List, Optional, Union
|
|
2
2
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
import pandas as pd
|
|
5
5
|
from pandas.core.arrays.timedeltas import TimedeltaArray
|
|
6
|
-
from pydantic import BaseModel
|
|
6
|
+
from pydantic import BaseModel, validator
|
|
7
7
|
|
|
8
8
|
from upgini.autofe.operand import PandasOperand
|
|
9
9
|
|
|
@@ -27,6 +27,17 @@ class DateDiff(PandasOperand, DateDiffMixin):
|
|
|
27
27
|
is_binary = True
|
|
28
28
|
has_symmetry_importance = True
|
|
29
29
|
|
|
30
|
+
def get_params(self) -> Dict[str, Optional[str]]:
|
|
31
|
+
res = super().get_params()
|
|
32
|
+
res.update(
|
|
33
|
+
{
|
|
34
|
+
"diff_unit": self.diff_unit,
|
|
35
|
+
"left_unit": self.left_unit,
|
|
36
|
+
"right_unit": self.right_unit,
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
return res
|
|
40
|
+
|
|
30
41
|
def calculate_binary(self, left: pd.Series, right: pd.Series) -> pd.Series:
|
|
31
42
|
left = self._convert_to_date(left, self.left_unit)
|
|
32
43
|
right = self._convert_to_date(right, self.right_unit)
|
|
@@ -42,6 +53,17 @@ class DateDiffType2(PandasOperand, DateDiffMixin):
|
|
|
42
53
|
is_binary = True
|
|
43
54
|
has_symmetry_importance = True
|
|
44
55
|
|
|
56
|
+
def get_params(self) -> Dict[str, Optional[str]]:
|
|
57
|
+
res = super().get_params()
|
|
58
|
+
res.update(
|
|
59
|
+
{
|
|
60
|
+
"diff_unit": self.diff_unit,
|
|
61
|
+
"left_unit": self.left_unit,
|
|
62
|
+
"right_unit": self.right_unit,
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
return res
|
|
66
|
+
|
|
45
67
|
def calculate_binary(self, left: pd.Series, right: pd.Series) -> pd.Series:
|
|
46
68
|
left = self._convert_to_date(left, self.left_unit)
|
|
47
69
|
right = self._convert_to_date(right, self.right_unit)
|
|
@@ -64,6 +86,15 @@ class DateListDiff(PandasOperand, DateDiffMixin):
|
|
|
64
86
|
has_symmetry_importance = True
|
|
65
87
|
aggregation: str
|
|
66
88
|
|
|
89
|
+
def get_params(self) -> Dict[str, Optional[str]]:
|
|
90
|
+
res = super().get_params()
|
|
91
|
+
res.update(
|
|
92
|
+
{
|
|
93
|
+
"aggregation": self.aggregation,
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
return res
|
|
97
|
+
|
|
67
98
|
def __init__(self, **data: Any) -> None:
|
|
68
99
|
if "name" not in data:
|
|
69
100
|
data["name"] = f"date_diff_{data.get('aggregation')}"
|
|
@@ -116,3 +147,55 @@ class DateListDiffBounded(DateListDiff):
|
|
|
116
147
|
def _agg(self, x):
|
|
117
148
|
x = x[(x >= (self.lower_bound or -np.inf)) & (x < (self.upper_bound or np.inf))]
|
|
118
149
|
return super()._agg(x)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class DatePercentile(PandasOperand):
|
|
153
|
+
name = "date_per"
|
|
154
|
+
is_binary = True
|
|
155
|
+
output_type = "float"
|
|
156
|
+
|
|
157
|
+
date_unit: Optional[str] = None
|
|
158
|
+
zero_month: Optional[int]
|
|
159
|
+
zero_year: Optional[int]
|
|
160
|
+
zero_bounds: Optional[List[float]]
|
|
161
|
+
step: int = 30
|
|
162
|
+
|
|
163
|
+
def get_params(self) -> Dict[str, Optional[str]]:
|
|
164
|
+
res = super().get_params()
|
|
165
|
+
res.update(
|
|
166
|
+
{
|
|
167
|
+
"date_unit": self.date_unit,
|
|
168
|
+
"zero_month": self.zero_month,
|
|
169
|
+
"zero_year": self.zero_year,
|
|
170
|
+
"zero_bounds": self.zero_bounds,
|
|
171
|
+
"step": self.step,
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
return res
|
|
175
|
+
|
|
176
|
+
@validator("zero_bounds", pre=True)
|
|
177
|
+
def validate_bounds(cls, value):
|
|
178
|
+
if value is None or isinstance(value, list):
|
|
179
|
+
return value
|
|
180
|
+
elif isinstance(value, str):
|
|
181
|
+
return value[1:-1].split(", ")
|
|
182
|
+
|
|
183
|
+
def calculate_binary(self, left: pd.Series, right: pd.Series) -> pd.Series:
|
|
184
|
+
# Assuming that left is a date column, right is a feature column
|
|
185
|
+
left = pd.to_datetime(left, unit=self.date_unit)
|
|
186
|
+
months = left.dt.month
|
|
187
|
+
years = left.dt.year
|
|
188
|
+
|
|
189
|
+
month_diffs = 12 * (years - (self.zero_year or 0)) + (months - (self.zero_month or 0))
|
|
190
|
+
bounds = month_diffs.apply(
|
|
191
|
+
lambda d: np.array(self.zero_bounds if self.zero_bounds is not None else []) + d * 30
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
return right.index.to_series().apply(lambda i: self.__perc(right[i], bounds[i]))
|
|
195
|
+
|
|
196
|
+
def __perc(self, f, bounds):
|
|
197
|
+
hit = np.where(f >= bounds)[0]
|
|
198
|
+
if hit.size > 0:
|
|
199
|
+
return np.max(hit) + 1
|
|
200
|
+
else:
|
|
201
|
+
return np.nan
|
upgini/autofe/feature.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import hashlib
|
|
2
2
|
import itertools
|
|
3
|
-
from typing import Dict, List, Optional, Tuple, Union
|
|
3
|
+
from typing import Dict, List, Optional, Set, Tuple, Union
|
|
4
4
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
import pandas as pd
|
|
@@ -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,19 +75,30 @@ 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
|
|
83
95
|
return self
|
|
84
96
|
|
|
97
|
+
def get_all_operand_names(self) -> Set[str]:
|
|
98
|
+
return {self.op.name}.union(
|
|
99
|
+
{n for f in self.children if isinstance(f, Feature) for n in f.get_all_operand_names()}
|
|
100
|
+
)
|
|
101
|
+
|
|
85
102
|
def rename_columns(self, mapping: Dict[str, str]) -> "Feature":
|
|
86
103
|
for child in self.children:
|
|
87
104
|
child.rename_columns(mapping)
|
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"
|
upgini/features_enricher.py
CHANGED
|
@@ -1452,15 +1452,12 @@ class FeaturesEnricher(TransformerMixin):
|
|
|
1452
1452
|
if len(decimal_columns_to_fix) > 0:
|
|
1453
1453
|
for col in decimal_columns_to_fix:
|
|
1454
1454
|
fitting_eval_X[col] = (
|
|
1455
|
-
fitting_eval_X[col]
|
|
1456
|
-
.astype("string").str
|
|
1457
|
-
.replace(",", ".", regex=False)
|
|
1458
|
-
.astype(np.float64)
|
|
1455
|
+
fitting_eval_X[col].astype("string").str.replace(",", ".", regex=False).astype(np.float64)
|
|
1459
1456
|
)
|
|
1460
1457
|
fitting_enriched_eval_X[col] = (
|
|
1461
1458
|
fitting_enriched_eval_X[col]
|
|
1462
|
-
.astype("string")
|
|
1463
|
-
.replace(",", ".", regex=False)
|
|
1459
|
+
.astype("string")
|
|
1460
|
+
.str.replace(",", ".", regex=False)
|
|
1464
1461
|
.astype(np.float64)
|
|
1465
1462
|
)
|
|
1466
1463
|
|
|
@@ -3279,10 +3276,16 @@ class FeaturesEnricher(TransformerMixin):
|
|
|
3279
3276
|
|
|
3280
3277
|
descriptions = []
|
|
3281
3278
|
for m in autofe_meta:
|
|
3282
|
-
autofe_feature = Feature.from_formula(m.formula)
|
|
3283
3279
|
orig_to_hashed = {base_column.original_name: base_column.hashed_name for base_column in m.base_columns}
|
|
3284
|
-
|
|
3285
|
-
autofe_feature
|
|
3280
|
+
|
|
3281
|
+
autofe_feature = (
|
|
3282
|
+
Feature.from_formula(m.formula)
|
|
3283
|
+
.set_display_index(m.display_index)
|
|
3284
|
+
.set_alias(m.alias)
|
|
3285
|
+
.set_op_params(m.operator_params or {})
|
|
3286
|
+
.rename_columns(orig_to_hashed)
|
|
3287
|
+
)
|
|
3288
|
+
|
|
3286
3289
|
if autofe_feature.op.is_vector:
|
|
3287
3290
|
continue
|
|
3288
3291
|
|
|
@@ -3303,7 +3306,7 @@ class FeaturesEnricher(TransformerMixin):
|
|
|
3303
3306
|
description[f"Feature {feature_idx}"] = bc.hashed_name
|
|
3304
3307
|
feature_idx += 1
|
|
3305
3308
|
|
|
3306
|
-
description["Function"] = autofe_feature.
|
|
3309
|
+
description["Function"] = ",".join(sorted(autofe_feature.get_all_operand_names()))
|
|
3307
3310
|
|
|
3308
3311
|
descriptions.append(description)
|
|
3309
3312
|
|
upgini/metadata.py
CHANGED
|
@@ -256,9 +256,11 @@ class BaseColumnMetadata(BaseModel):
|
|
|
256
256
|
|
|
257
257
|
|
|
258
258
|
class GeneratedFeatureMetadata(BaseModel):
|
|
259
|
-
|
|
259
|
+
alias: Optional[str]
|
|
260
|
+
formula: str
|
|
260
261
|
display_index: str
|
|
261
262
|
base_columns: List[BaseColumnMetadata]
|
|
263
|
+
operator_params: Optional[Dict[str, str]]
|
|
262
264
|
|
|
263
265
|
|
|
264
266
|
class ProviderTaskMetadataV2(BaseModel):
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
upgini/__about__.py,sha256=
|
|
1
|
+
upgini/__about__.py,sha256=M8oRdaN0OaDPoFncIo2PvsDEQ9MJDWvpN-9TQE9lVLs,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
|
|
5
5
|
upgini/errors.py,sha256=2b_Wbo0OYhLUbrZqdLIx5jBnAsiD1Mcenh-VjR4HCTw,950
|
|
6
|
-
upgini/features_enricher.py,sha256=
|
|
6
|
+
upgini/features_enricher.py,sha256=oFrqaCKlKLol0OGJO3JkA83UisUkr2wb8pHbqKC58Do,177543
|
|
7
7
|
upgini/http.py,sha256=khrYSldpY-HbVLCcApfV1BjBFK6Uyuatb4colKybxgY,42301
|
|
8
|
-
upgini/metadata.py,sha256=
|
|
8
|
+
upgini/metadata.py,sha256=qDAIO7NLSSQp_XiXCv3U4XJTLO0KH3YuQ8lvCLYPqzs,9781
|
|
9
9
|
upgini/metrics.py,sha256=DLvA2YLV4f7lnzBCcfZ5T4NkqAv3pbstbjTepavuT7U,30688
|
|
10
10
|
upgini/search_task.py,sha256=LtRJ9bCPjMo1gJ-sUDKERhDwGcWKImrzwVFHjkMSQHQ,17071
|
|
11
11
|
upgini/spinner.py,sha256=4iMd-eIe_BnkqFEMIliULTbj6rNI2HkN_VJ4qYe0cUc,1118
|
|
@@ -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=Ia8qfYagUux-B5rsCgR-3PdJ_9uJ0HGJBbwAs8Dj7o4,6731
|
|
19
|
+
upgini/autofe/feature.py,sha256=_V9B74B3ue7eAYXSOt9JKhVC9klkAKks22MwnBRye_w,12487
|
|
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=N-eJrfAJxYpDPc85sKQyMFcIeL9Ug2lwlqDyS4jFOdE,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.285a3418.post1.dist-info/METADATA,sha256=Imf9T1uNKkL0_2VyaPtV8b-ZWqTAvINqnaxBJ-gxaRQ,48128
|
|
60
|
+
upgini-1.1.285a3418.post1.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
|
|
61
|
+
upgini-1.1.285a3418.post1.dist-info/licenses/LICENSE,sha256=5RRzgvdJUu3BUDfv4bzVU6FqKgwHlIay63pPCSmSgzw,1514
|
|
62
|
+
upgini-1.1.285a3418.post1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|