Revenue Forecasting
Forecast revenue for products in the food and beverages industry using panel data with 50 products tracked over 100 time periods.
Dataset Exploration
The Food & Beverages dataset contains sales and inventory data for retail food products. Features include pricing, advertising spend, store traffic, competitor activity, and more. The target variable predicts revenue to optimize inventory management and pricing strategies.
Panel data structure: 50 products tracked over 100 time periods (5,000 total rows, 13 columns). Notice how Product 1 appears across multiple consecutive time periods — this is panel data.
Fit Data (first 5 rows)
| Product | Time | Price | Add_spend | Store_traffic | Log_inventory | Competitor_price | Comp._promo | Price_X_Promo | Add_X_Price | Store_size | Cust_demo | Revenue |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 43831 | 3.37 | 465.27 | 2.56 | 4.12 | 3.78 | 0 | 0 | 1758.72 | 2290 | 3 | 145623 |
| 1 | 43832 | 3.73 | 423.33 | 3.06 | 3.64 | 3.61 | 1 | 3.73 | 1528.22 | 2290 | 3 | 142171.2 |
| 1 | 43833 | 3.39 | 555.51 | 2.86 | 4.02 | 2.94 | 0 | 0 | 1633.2 | 2290 | 3 | 145126.3 |
| 1 | 43834 | 3.41 | 487.45 | 2.79 | 4.07 | 3.58 | 0 | 0 | 1745.07 | 2290 | 3 | 145192.8 |
| 1 | 43835 | 3.12 | 525.51 | 3.17 | 3.97 | 3.63 | 0 | 0 | 1907.6 | 2290 | 3 | 147483.7 |
Forecast Data (first 3 rows)
The forecast file has the same structure but covers future periods without the Revenue column. DATFID uses this to know which products and time points to predict.
| Product | Time | Price | Add_spend | Store_traffic | Log_inventory | Competitor_price | Comp._promo | Price_X_Promo | Add_X_Price | Store_size | Cust_demo |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 43931 | 3.55 | 490.12 | 2.78 | 4.05 | 3.45 | 0 | 0 | 1650.3 | 2290 | 3 |
| 1 | 43932 | 3.62 | 510.44 | 3.01 | 3.88 | 3.52 | 1 | 3.62 | 1720.15 | 2290 | 3 |
| 1 | 43933 | 3.48 | 475.8 | 2.95 | 4.1 | 3.38 | 0 | 0 | 1590.22 | 2290 | 3 |
Download sample datasets from GitHub — also works with CSV files.
Code Walkthrough
Step 1: Initialize
import pandas as pd
from datfid import DATFIDClient
client = DATFIDClient(token="your_DATFID_token")Step 2: Fit the Model
url_fit = "https://raw.githubusercontent.com/datfid-valeriidashuk/sample-datasets/main/Food_Beverages.xlsx"
df = pd.read_excel(url_fit)
result = client.fit_model(
df=df,
id_col="Product",
time_col="Time",
y="Revenue",
current_features="all",
filter_by_significance=True
)Step 3: Forecast
url_forecast = "https://raw.githubusercontent.com/datfid-valeriidashuk/sample-datasets/main/Food_Beverages_forecast.xlsx"
df_forecast = pd.read_excel(url_forecast)
forecast = client.forecast_model(df_forecast=df_forecast)Analysis Results (Model Fit)
Formula
Revenue ~ α1*Intercept + α2*Store_size + α3*Cust_demo + β1*Price + β2*Add_spend + β3*Store_traffic + β4*Log_inventory + β5*Competitor_price + β6*Competitor_promotionAlpha Estimates (Time-Invariant)
Characteristics constant across time — inherent properties of each product.
| Variable | Estimate | T-stat | Interpretation |
|---|---|---|---|
| Intercept | -14,962.3 | 184.5 | Baseline revenue offset (large negative because the model centres on store and demographic effects). |
| Store_size | +49.9 | 1,355.8 | Each unit of store size adds ~49.9 to revenue. |
| Cust_demo | +546.3 | 56.4 | Each step up in customer-demographics index adds ~546.3 to revenue. |
Beta Estimates (Time-Varying)
| Variable | Estimate | T-stat | Interpretation |
|---|---|---|---|
| Price | -332.6 | 11.6 | Each $1 increase in price subtracts ~332.6 in revenue — the headline elasticity. |
| Add_spend | +53.2 | 408.3 | Each $1 of advertising spend lifts revenue by ~53.2 — strong ROAS. |
| Store_traffic | -52.9 | 1.4 | Foot traffic moves revenue slightly down in this run, but the effect is not statistically significant. |
| Log_inventory | +219.6 | 5.0 | A 1-unit increase in log inventory adds ~219.6 to revenue. |
| Competitor_price | +5,307.7 | 182.7 | Each $1 a competitor raises their price adds ~5,307.7 to our revenue — strong cross-elasticity. |
| Competitor_promotion | -104.8 | 7.0 | A 1-unit increase in competitor promotion subtracts ~104.8 from revenue. |
Model Performance
Try it yourself: Run this exact analysis in the Free Playground — select "Food Beverages" from the sample datasets and click Run Analysis.