upgini 1.1.281__tar.gz → 1.1.282a3418.post1__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 upgini might be problematic. Click here for more details.

Files changed (64) hide show
  1. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/PKG-INFO +1 -1
  2. upgini-1.1.282a3418.post1/src/upgini/__about__.py +1 -0
  3. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/autofe/all_operands.py +2 -1
  4. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/autofe/date.py +86 -2
  5. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/autofe/feature.py +16 -4
  6. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/autofe/operand.py +4 -2
  7. upgini-1.1.281/src/upgini/__about__.py +0 -1
  8. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/.gitignore +0 -0
  9. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/LICENSE +0 -0
  10. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/README.md +0 -0
  11. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/pyproject.toml +0 -0
  12. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/__init__.py +0 -0
  13. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/ads.py +0 -0
  14. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/ads_management/__init__.py +0 -0
  15. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/ads_management/ads_manager.py +0 -0
  16. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/autofe/__init__.py +0 -0
  17. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/autofe/binary.py +0 -0
  18. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/autofe/groupby.py +0 -0
  19. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/autofe/unary.py +0 -0
  20. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/autofe/vector.py +0 -0
  21. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/data_source/__init__.py +0 -0
  22. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/data_source/data_source_publisher.py +0 -0
  23. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/dataset.py +0 -0
  24. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/errors.py +0 -0
  25. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/features_enricher.py +0 -0
  26. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/http.py +0 -0
  27. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/mdc/__init__.py +0 -0
  28. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/mdc/context.py +0 -0
  29. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/metadata.py +0 -0
  30. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/metrics.py +0 -0
  31. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/normalizer/__init__.py +0 -0
  32. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/normalizer/phone_normalizer.py +0 -0
  33. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/resource_bundle/__init__.py +0 -0
  34. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/resource_bundle/exceptions.py +0 -0
  35. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/resource_bundle/strings.properties +0 -0
  36. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/resource_bundle/strings_widget.properties +0 -0
  37. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/sampler/__init__.py +0 -0
  38. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/sampler/base.py +0 -0
  39. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/sampler/random_under_sampler.py +0 -0
  40. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/sampler/utils.py +0 -0
  41. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/search_task.py +0 -0
  42. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/spinner.py +0 -0
  43. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/__init__.py +0 -0
  44. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/base_search_key_detector.py +0 -0
  45. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/blocked_time_series.py +0 -0
  46. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/country_utils.py +0 -0
  47. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/custom_loss_utils.py +0 -0
  48. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/cv_utils.py +0 -0
  49. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/datetime_utils.py +0 -0
  50. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/deduplicate_utils.py +0 -0
  51. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/display_utils.py +0 -0
  52. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/email_utils.py +0 -0
  53. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/fallback_progress_bar.py +0 -0
  54. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/features_validator.py +0 -0
  55. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/format.py +0 -0
  56. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/ip_utils.py +0 -0
  57. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/phone_utils.py +0 -0
  58. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/postal_code_utils.py +0 -0
  59. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/progress_bar.py +0 -0
  60. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/sklearn_ext.py +0 -0
  61. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/target_utils.py +0 -0
  62. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/track_info.py +0 -0
  63. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/utils/warning_counter.py +0 -0
  64. {upgini-1.1.281 → upgini-1.1.282a3418.post1}/src/upgini/version_validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: upgini
3
- Version: 1.1.281
3
+ Version: 1.1.282a3418.post1
4
4
  Summary: Intelligent data search & enrichment for Machine Learning
5
5
  Project-URL: Bug Reports, https://github.com/upgini/upgini/issues
6
6
  Project-URL: Homepage, https://upgini.com/
@@ -0,0 +1 @@
1
+ __version__ = "1.1.282a3418-1"
@@ -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
 
@@ -1,9 +1,10 @@
1
- from typing import Any, Optional, Union
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
@@ -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("_".join([self.op.name] + [ch.name for ch in self.children]).encode("utf-8")).hexdigest()[
78
- :8
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
@@ -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
- return self.params
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 +0,0 @@
1
- __version__ = "1.1.281"
File without changes
File without changes
File without changes