Python SDK
The official DATFID Python package for interpretable AI forecasting. Available on PyPI.
Installation
Terminal
pip install datfidInitialize the Client
Python
import pandas as pd
from datfid import DATFIDClient
client = DATFIDClient(token="your_DATFID_token")Need a token? See Get Your API Key.
Supported File Formats
DATFID accepts Excel (.xlsx, .xls) and CSV (.csv) for both model fitting and forecasting inputs.
fit_model()
Trains an interpretable panel data model on your dataset and returns a formula with coefficients.
Python
result = client.fit_model(
df=df,
id_col="Product",
time_col="Time",
y="Revenue",
current_features="all",
filter_by_significance=True,
lag_y="1:3",
lagged_features={"Income Level": "1:3"}
)Parameters
| Parameter | Required | Description |
|---|---|---|
df | Required | Pandas DataFrame with your historical panel data |
id_col | Required | Column name identifying each entity (product, customer, store, etc.) |
time_col | Required | Column name for the time dimension |
y | Required | Column name of the target variable to predict |
current_features | Optional | Which features to include. Use "all" for all columns, a list of column names for a subset, or omit to use only the mandatory columns (id, time, target). |
filter_by_significance | Optional | When True, DATFID automatically removes statistically insignificant features, keeping only variables with a meaningful relationship to the target. Simplifies the model and avoids noise. Recommended for most use cases. |
lag_y | Optional | Include lagged values of the target variable as features. E.g. "1:3" uses the target's values from 1, 2, and 3 periods ago. Useful for autoregressive patterns. |
lagged_features | Optional | Include lagged values of specific features. Pass a dict mapping feature names to lag ranges, e.g. {"Income Level": "1:3"}. Useful when the effect of a feature is delayed (e.g. marketing spend affects sales with a lag). |
forecast_model()
Generates predictions using the previously fitted model. Requires a forecast DataFrame that defines which entities and time periods to predict.
Python
df_forecast = pd.read_excel("forecast_data.xlsx")
forecast = client.forecast_model(df_forecast=df_forecast)Parameters
| Parameter | Required | Description |
|---|---|---|
df_forecast | Required | DataFrame with the same entity/time structure as the fit data, covering the periods you want predictions for. Must include feature columns if the model uses them. |
Use Case Examples
See the SDK in action with real datasets, analysis results, and forecast outputs:
- → Revenue Forecasting — Food & Beverages industry
- → Loan Probability — Banking sector with lagged features
- → Energy Electricity — Regional demand forecasting
- → Insurance — Premium pricing & risk
- → M5 Department — Retail department-level sales
- → Payments — Transaction volume forecasting
- → Venture Capital — Investment risk scoring
Want to try without code? The Free Playground exposes all the same parameters (feature selection, lags, filter by significance) through a point-and-click UI — no SDK installation required.