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*Cust_demo + α3*Store_size + β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 | 184.50 | Baseline revenue level |
| Store_size | +49.89 | 1,355.75 | Each sq-ft of store size adds ~$49.89 to baseline revenue (strongest predictor) |
| Cust_demo | +546.34 | 56.43 | Each unit increase in customer demographic score adds ~$546 to baseline revenue |
Beta Estimates (Time-Varying)
| Variable | Estimate | T-stat | Interpretation |
|---|---|---|---|
| Competitor_price | +5,307.74 | 182.73 | Higher competitor prices strongly increase own revenue (customers switch) |
| Add_spend | +53.23 | 408.27 | Each $1 of ad spend adds ~$53 in revenue (excellent ROI) |
| Log_inventory | +219.58 | 5.03 | Higher inventory levels increase revenue |
| Price | -332.59 | 11.57 | A $1 price increase reduces revenue by ~$333 (price sensitivity) |
| Competitor_promotion | -104.76 | 6.98 | Competitor promotions decrease own revenue by ~$105 |
| Store_traffic | -52.85 | 1.42 | Not statistically significant (p=0.15) |
Model Performance
Try it yourself: Run this exact analysis in the Free Playground — select "Food Beverages" from the sample datasets and click Run Analysis.