datfid 0.1.17__tar.gz → 0.1.19__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.17
3
+ Version: 0.1.19
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
@@ -13,6 +13,27 @@ import logging
13
13
  class FitResult(SimpleNamespace):
14
14
  _ROW4 = ["Estimate", "Standard Error", "T statistic", "P value"]
15
15
  _PERF5 = ["R2 within", "R2 between", "R2 overall", "MSE", "MAE"]
16
+
17
+ @property
18
+ def id(self):
19
+ import pandas as pd
20
+ if hasattr(self, "df") and isinstance(self.df, pd.DataFrame) and "ID" in self.df.columns:
21
+ return pd.DataFrame(self.df["ID"].astype(str).unique())
22
+ return pd.DataFrame([])
23
+
24
+ @property
25
+ def ID(self):
26
+ import pandas as pd
27
+ if hasattr(self, "df") and isinstance(self.df, pd.DataFrame) and "ID" in self.df.columns:
28
+ return pd.DataFrame(self.df["ID"].astype(str).unique())
29
+ return pd.DataFrame([])
30
+
31
+ @property
32
+ def Id(self):
33
+ import pandas as pd
34
+ if hasattr(self, "df") and isinstance(self.df, pd.DataFrame) and "ID" in self.df.columns:
35
+ return pd.DataFrame(self.df["ID"].astype(str).unique())
36
+ return pd.DataFrame([])
16
37
 
17
38
  @staticmethod
18
39
  def _df4(rows_list):
@@ -38,6 +59,20 @@ class FitResult(SimpleNamespace):
38
59
  kwargs["df"] = pd.DataFrame(kwargs["df"])
39
60
  super().__init__(**kwargs)
40
61
 
62
+ class FitResultDict(dict):
63
+ @property
64
+ def id(self):
65
+ return pd.DataFrame({"ID": list(self.keys())})
66
+
67
+ @property
68
+ def ID(self):
69
+ return pd.DataFrame({"ID": list(self.keys())})
70
+
71
+ @property
72
+ def Id(self):
73
+ return pd.DataFrame({"ID": list(self.keys())})
74
+
75
+
41
76
  class DATFIDClient:
42
77
  def __init__(self, token: str):
43
78
  self.api_url = "https://datfid-org-datfid-sdk.hf.space/"
@@ -185,7 +220,7 @@ class DATFIDClient:
185
220
  current_features: Optional[list] = None,
186
221
  filter_by_significance: bool = False,
187
222
  meanvar_test: bool = False
188
- ) -> Dict[str, FitResult]:
223
+ ) -> FitResultDict:
189
224
  """
190
225
  Fit a model individual by individual using the DATFID API.
191
226
 
@@ -229,10 +264,10 @@ class DATFIDClient:
229
264
  if response.status_code != 200:
230
265
  raise Exception(f"Model fit failed: {response.text}")
231
266
 
232
- raw = response.json() # { "<id>": { ... per-id result ... }, ... }
267
+ raw = response.json()
233
268
  # 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]
269
+ result_per_id = FitResultDict({str(k): FitResult(**v) for k, v in raw.items()})
270
+ return result_per_id # FitResultDict[str, SimpleNamespace]
236
271
 
237
272
  def forecast_model_ind(
238
273
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datfid
3
- Version: 0.1.17
3
+ Version: 0.1.19
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.17",
20
+ version="0.1.19",
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