datfid 0.1.15__tar.gz → 0.1.17__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 datfid might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datfid
3
- Version: 0.1.15
3
+ Version: 0.1.17
4
4
  Summary: SDK to access the DATFID API hosted on Hugging Face Spaces
5
5
  Author: DATFID
6
6
  Author-email: igor.schapiro@datfid.com
@@ -9,6 +9,35 @@ import gc
9
9
  import psutil
10
10
  import logging
11
11
 
12
+ # for nice output
13
+ class FitResult(SimpleNamespace):
14
+ _ROW4 = ["Estimate", "Standard Error", "T statistic", "P value"]
15
+ _PERF5 = ["R2 within", "R2 between", "R2 overall", "MSE", "MAE"]
16
+
17
+ @staticmethod
18
+ def _df4(rows_list):
19
+ if not isinstance(rows_list, list):
20
+ return rows_list
21
+ return pd.DataFrame(rows_list, index=FitResult._ROW4[:len(rows_list)])
22
+
23
+ @staticmethod
24
+ def _df_perf(rows_list):
25
+ if not isinstance(rows_list, list):
26
+ return rows_list
27
+ return pd.DataFrame(rows_list, index=FitResult._PERF5[:len(rows_list)])
28
+
29
+ def __init__(self, **kwargs):
30
+ # Convert list→DataFrame for table-like fields
31
+ if "alpha" in kwargs:
32
+ kwargs["alpha"] = self._df4(kwargs["alpha"])
33
+ if "beta" in kwargs:
34
+ kwargs["beta"] = self._df4(kwargs["beta"])
35
+ if "Performance" in kwargs:
36
+ kwargs["Performance"] = self._df_perf(kwargs["Performance"])
37
+ if "df" in kwargs and isinstance(kwargs["df"], list):
38
+ kwargs["df"] = pd.DataFrame(kwargs["df"])
39
+ super().__init__(**kwargs)
40
+
12
41
  class DATFIDClient:
13
42
  def __init__(self, token: str):
14
43
  self.api_url = "https://datfid-org-datfid-sdk.hf.space/"
@@ -54,7 +83,7 @@ class DATFIDClient:
54
83
  current_features: Optional[list] = None,
55
84
  filter_by_significance: bool = False,
56
85
  meanvar_test: bool = False
57
- ) -> SimpleNamespace:
86
+ ) -> FitResult:
58
87
  """
59
88
  Fit a model using the DATFID API.
60
89
 
@@ -99,8 +128,8 @@ class DATFIDClient:
99
128
  raise Exception(f"Model fit failed: {response.text}")
100
129
 
101
130
  result_dict = response.json()
102
- return SimpleNamespace(**result_dict)
103
-
131
+ return FitResult(**result_dict)
132
+
104
133
  def forecast_model(
105
134
  self,
106
135
  df_forecast: pd.DataFrame
@@ -156,7 +185,7 @@ class DATFIDClient:
156
185
  current_features: Optional[list] = None,
157
186
  filter_by_significance: bool = False,
158
187
  meanvar_test: bool = False
159
- ) -> SimpleNamespace:
188
+ ) -> Dict[str, FitResult]:
160
189
  """
161
190
  Fit a model individual by individual using the DATFID API.
162
191
 
@@ -200,8 +229,10 @@ class DATFIDClient:
200
229
  if response.status_code != 200:
201
230
  raise Exception(f"Model fit failed: {response.text}")
202
231
 
203
- result_dict = response.json()
204
- return SimpleNamespace(**result_dict)
232
+ raw = response.json() # { "<id>": { ... per-id result ... }, ... }
233
+ # Wrap each per-id result into a SimpleNamespace for dot access:
234
+ result_per_id = {str(k): FitResult(**v) for k, v in raw.items()}
235
+ return result_per_id # Dict[str, SimpleNamespace]
205
236
 
206
237
  def forecast_model_ind(
207
238
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datfid
3
- Version: 0.1.15
3
+ Version: 0.1.17
4
4
  Summary: SDK to access the DATFID API hosted on Hugging Face Spaces
5
5
  Author: DATFID
6
6
  Author-email: igor.schapiro@datfid.com
@@ -17,7 +17,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
17
17
 
18
18
  setup(
19
19
  name="datfid",
20
- version="0.1.15",
20
+ version="0.1.17",
21
21
  description="SDK to access the DATFID API hosted on Hugging Face Spaces",
22
22
  long_description=long_description,
23
23
  long_description_content_type="text/markdown", # Important!
File without changes
File without changes
File without changes
File without changes