datfid 0.1.12__py3-none-any.whl → 0.1.13__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.
@@ -0,0 +1,155 @@
1
+ Metadata-Version: 2.4
2
+ Name: datfid
3
+ Version: 0.1.13
4
+ Summary: SDK to access the DATFID API hosted on Hugging Face Spaces
5
+ Author: DATFID
6
+ Author-email: igor.schapiro@datfid.com
7
+ License: MIT
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Requires-Python: >=3.7
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: requests>=2.31.0
14
+ Requires-Dist: pandas>=1.0.1
15
+ Requires-Dist: numpy<2.1,>=1.22
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: license
22
+ Dynamic: license-file
23
+ Dynamic: requires-dist
24
+ Dynamic: requires-python
25
+ Dynamic: summary
26
+
27
+ # DATFID SDK
28
+
29
+ A Python SDK to access the DATFID API to forecast your data.
30
+
31
+ ## Features
32
+
33
+ - **Easy model fitting**: Build panel data models with time-dependent and static features.
34
+ - **Flexible lag handling**: Specify lags for the dependent variable and selected features.
35
+ - **Forecasting**: Generate future predictions with aligned timestamps and IDs.
36
+ - **Statistical options**: Filter features by significance and apply mean-variance tests.
37
+ - **White box full interpretability**: Get fully interpretable model with equation, estimated parameters, and standard errors.
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install datfid
43
+ ```
44
+
45
+ ## Usage
46
+
47
+ Before using the SDK, please request an access token by emailing **admin@datfid.com** or by visiting our website [datfid.com](https://datfid.com).
48
+
49
+ ```python
50
+ from datfid import DATFIDClient
51
+
52
+ # Initialize the client with your DATFID token
53
+ client = DATFIDClient(token="your_DATFID_token")
54
+
55
+ # Fit a model
56
+ fit_result = client.fit_model(
57
+ df=dataframe,
58
+ id_col="name of id column",
59
+ time_col="name of time column",
60
+ y="name of dependent variable",
61
+ lag_y="starting lag : ending lag",
62
+ lagged_features={
63
+ "feature 1": "starting lag : ending lag",
64
+ "feature 2": "starting lag : ending lag"
65
+ },
66
+ current_features=["feature 3", "feature 4"],
67
+ filter_by_significance=True/False,
68
+ meanvar_test=True/False
69
+ )
70
+
71
+ # Generate forecasts
72
+ forecast_df = client.forecast_model(
73
+ df_forecast=dataframe
74
+ )
75
+
76
+ # The forecast DataFrame contains the individual IDs and timestamps
77
+ # from the original data plus a "forecast" column with predicted values.
78
+ ```
79
+
80
+ ## Example 1
81
+
82
+ Sample dataset from GitHub (Food and Beverages demand forecasting):
83
+
84
+ ```python
85
+ import pandas as pd
86
+ from datfid import DATFIDClient
87
+
88
+ # Initialize the client with your DATFID token
89
+ client = DATFIDClient(token="your_DATFID_token")
90
+
91
+ # Load dataset for model fitting
92
+ url_fit = "https://raw.githubusercontent.com/datfid-valeriidashuk/sample-datasets/main/Food_Beverages.xlsx"
93
+ df = pd.read_excel(url_fit)
94
+
95
+ # Fit the model
96
+ result = client.fit_model(df=df,
97
+ id_col="Product",
98
+ time_col="Time",
99
+ y="Revenue",
100
+ current_features='all',
101
+ filter_by_significance=True
102
+ )
103
+
104
+ # Load dataset for forecasting
105
+ url_forecast = "https://raw.githubusercontent.com/datfid-valeriidashuk/sample-datasets/main/Food_Beverages_forecast.xlsx"
106
+ df_forecast = pd.read_excel(url_forecast)
107
+
108
+ # Forecast revenue using the fitted model
109
+ forecast = client.forecast_model(df_forecast=df_forecast)
110
+ ```
111
+
112
+ ## Example 2
113
+
114
+ Slightly larger sample dataset from GitHub (Banking sector, forecasting loan probability):
115
+
116
+ ```python
117
+ import pandas as pd
118
+ from datfid import DATFIDClient
119
+
120
+ # Initialize the client with your DATFID token
121
+ client = DATFIDClient(token="your_DATFID_token")
122
+
123
+ # Load dataset for model fitting
124
+ url_fit = "https://raw.githubusercontent.com/datfid-valeriidashuk/sample-datasets/main/Banking_extended.xlsx"
125
+ df = pd.read_excel(url_fit)
126
+
127
+ # Fit the model
128
+ result = client.fit_model(df=df,
129
+ id_col="Individual",
130
+ time_col="Time",
131
+ y="Loan Probability",
132
+ lag_y="1:3",
133
+ lagged_features={"Income Level": "1:3"},
134
+ filter_by_significance=True)
135
+
136
+ # Load dataset for forecasting
137
+ url_forecast = "https://raw.githubusercontent.com/datfid-valeriidashuk/sample-datasets/main/Banking_extended_forecast.xlsx"
138
+ df_forecast = pd.read_excel(url_forecast)
139
+
140
+ # Forecast loan probability using the fitted model
141
+ forecast = client.forecast_model(df_forecast=df_forecast)
142
+ ```
143
+
144
+ ## API Reference
145
+
146
+ ### DATFIDClient
147
+
148
+ #### `client = DATFIDClient(token: str)`
149
+ Initialize the client with your DATFID token.
150
+
151
+ #### `client.fit_model(df: pd.DataFrame, id_col: str, time_col: str, y: str, lag_y: Optional[Union[int, str, list[int]]] = None, lagged_features: Optional[Dict[str, int]] = None, current_features: Optional[list] = None, filter_by_significance: bool = False, meanvar_test: bool = False) -> SimpleNamespace`
152
+ Fit a model using the provided dataset.
153
+
154
+ #### `client.forecast_model(df_forecast: pd.DataFrame) -> pd.DataFrame`
155
+ Generate forecasts using the fitted model.
@@ -0,0 +1,7 @@
1
+ datfid/__init__.py,sha256=PojdUQsimZvawR8lgqVpzs3EkRtkA7iwuDk7fovJF54,34
2
+ datfid/client.py,sha256=XH8wTBsHOHT3Fl1DzDWP9PfIUxJGg24eLH7_cWuymic,4656
3
+ datfid-0.1.13.dist-info/licenses/LICENSE,sha256=5b2JLb1-P8Nt919phjUmP0umS82SxGMlIF2QFn9ILgM,1084
4
+ datfid-0.1.13.dist-info/METADATA,sha256=fleRinV54vP271uLNgLk5sTyQDy4zxw-edkcF3dSIjE,5146
5
+ datfid-0.1.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ datfid-0.1.13.dist-info/top_level.txt,sha256=VFG23u9NMNQJ8S_IFfW-S5d8oSUd71SFA346ovh_uxA,7
7
+ datfid-0.1.13.dist-info/RECORD,,
@@ -1,87 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: datfid
3
- Version: 0.1.12
4
- Summary: SDK to access the DATFID API hosted on Hugging Face Spaces
5
- Author: DATFID
6
- Author-email: igor.schapiro@datfid.com
7
- License: MIT
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Programming Language :: Python :: 3
10
- Requires-Python: >=3.7
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE
13
- Requires-Dist: requests>=2.31.0
14
- Requires-Dist: pandas>=1.0.1
15
- Requires-Dist: numpy<2.1,>=1.22
16
- Dynamic: author
17
- Dynamic: author-email
18
- Dynamic: classifier
19
- Dynamic: description
20
- Dynamic: description-content-type
21
- Dynamic: license
22
- Dynamic: license-file
23
- Dynamic: requires-dist
24
- Dynamic: requires-python
25
- Dynamic: summary
26
-
27
- # DATFID SDK
28
-
29
- A Python SDK to access the DATFID API running on Hugging Face Spaces.
30
-
31
- ## Installation
32
-
33
- ```bash
34
- pip install datfid
35
- ```
36
-
37
- ## Usage
38
-
39
- ```python
40
- from datfid import DATFIDClient
41
-
42
- # Initialize the client with your Hugging Face token
43
- client = DATFIDClient(token="your_huggingface_token")
44
-
45
- # Fit a model
46
- fit_result = client.fit_model(
47
- file_path="path/to/your/data.xlsx",
48
- id_col="Individual",
49
- time_col="Time",
50
- y="Loan Probability",
51
- lagged_features={"Repayment Amount": 1, "Missed Payments": 2},
52
- current_features=["Credit Score", "Unemployment Rate"],
53
- filter_by_significance=True,
54
- meanvar_test=False
55
- )
56
-
57
- # Generate forecasts
58
- forecast_df = client.generate_forecast(
59
- file_path="path/to/your/forecast_data.xlsx",
60
- id_col="Individual",
61
- time_col="Time",
62
- y="Loan Probability",
63
- lagged_features={"Repayment Amount": 1, "Missed Payments": 2},
64
- current_features=["Credit Score", "Unemployment Rate"],
65
- filter_by_significance=True,
66
- meanvar_test=False
67
- )
68
-
69
- # The forecast DataFrame includes the original data plus forecast columns:
70
- # - forecast: The predicted values
71
- # - forecast_lower: Lower bound of the prediction interval
72
- # - forecast_upper: Upper bound of the prediction interval
73
- # - forecast_error: Standard error of the forecast
74
- ```
75
-
76
- ## API Reference
77
-
78
- ### DATFIDClient
79
-
80
- #### `__init__(token: str)`
81
- Initialize the client with your Hugging Face token.
82
-
83
- #### `fit_model(file_path: str, id_col: str, time_col: str, y: str, lagged_features: Optional[Dict[str, int]] = None, current_features: Optional[list] = None, filter_by_significance: bool = False, meanvar_test: bool = False) -> Dict[str, Any]`
84
- Fit a model using the provided data.
85
-
86
- #### `generate_forecast(file_path: str, id_col: str, time_col: str, y: str, lagged_features: Optional[Dict[str, int]] = None, current_features: Optional[list] = None, filter_by_significance: bool = False, meanvar_test: bool = False) -> pd.DataFrame`
87
- Generate forecasts using the fitted model.
@@ -1,7 +0,0 @@
1
- datfid/__init__.py,sha256=PojdUQsimZvawR8lgqVpzs3EkRtkA7iwuDk7fovJF54,34
2
- datfid/client.py,sha256=XH8wTBsHOHT3Fl1DzDWP9PfIUxJGg24eLH7_cWuymic,4656
3
- datfid-0.1.12.dist-info/licenses/LICENSE,sha256=5b2JLb1-P8Nt919phjUmP0umS82SxGMlIF2QFn9ILgM,1084
4
- datfid-0.1.12.dist-info/METADATA,sha256=cTQxUumLGxbsYwS09JxmJJrOIcit1ZCgeKE-nenwd-I,2750
5
- datfid-0.1.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- datfid-0.1.12.dist-info/top_level.txt,sha256=VFG23u9NMNQJ8S_IFfW-S5d8oSUd71SFA346ovh_uxA,7
7
- datfid-0.1.12.dist-info/RECORD,,