Interpretable AI forecasting for Python
pip install datfidForecast revenue for products in the food and beverages industry.
import pandas as pd
from datfid import DATFIDClient
# Initialize the client
client = DATFIDClient(token="your_DATFID_token")# Load dataset for model fitting
url_fit = "https://raw.githubusercontent.com/datfid-valeriidashuk/sample-datasets/main/Food_Beverages.xlsx"
df = pd.read_excel(url_fit)
# Fit the model
result = client.fit_model(df=df,
id_col="Product",
time_col="Time",
y="Revenue",
current_features='all',
filter_by_significance=True
)fit_model methodcurrent_features parameter is optional — in this example, we set it to 'all' to use all available columns in the dataset as features# Load dataset for forecasting
url_forecast = "https://raw.githubusercontent.com/datfid-valeriidashuk/sample-datasets/main/Food_Beverages_forecast.xlsx"
df_forecast = pd.read_excel(url_forecast)
# Forecast revenue
forecast = client.forecast_model(df_forecast=df_forecast)forecast_model method uses the previously fitted model to predict future revenue values based on the features in your forecast datasetPredict loan probabilities in the banking sector with lagged features.
import pandas as pd
from datfid import DATFIDClient
# Initialize the client
client = DATFIDClient(token="your_DATFID_token")# Load dataset for model fitting
url_fit = "https://raw.githubusercontent.com/datfid-valeriidashuk/sample-datasets/main/Banking_extended.xlsx"
df = pd.read_excel(url_fit)
# Fit the model with lagged features
result = client.fit_model(df=df,
id_col="Individual",
time_col="Time",
y="Loan Probability",
lag_y="1:3",
lagged_features={"Income Level": "1:3"},
filter_by_significance=True)fit_model methodlag_y and lagged_features control how much historical data is taken into consideration for the analysis (the lag)lag_y="1:3" means 3 lags (lag 1, lag 2, and lag 3) of the target variablelagged_features={"Income Level": "1:3"} means the "Income Level" feature will include 3 historical lags# Load dataset for forecasting
url_forecast = "https://raw.githubusercontent.com/datfid-valeriidashuk/sample-datasets/main/Banking_extended_forecast.xlsx"
df_forecast = pd.read_excel(url_forecast)
# Forecast loan probability
forecast = client.forecast_model(df_forecast=df_forecast)forecast_model method uses the previously fitted model (including the lagged features) to predict future loan probability values based on the features in your forecast datasetGet instant access to the DATFID API with our free trial. No credit card required.
The official DATFID Python package is available on PyPI for easy installation.