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)

ProductTimePriceAdd_spendStore_trafficLog_inventoryCompetitor_priceComp._promoPrice_X_PromoAdd_X_PriceStore_sizeCust_demoRevenue
1438313.37465.272.564.123.78001758.7222903145623
1438323.73423.333.063.643.6113.731528.2222903142171.2
1438333.39555.512.864.022.94001633.222903145126.3
1438343.41487.452.794.073.58001745.0722903145192.8
1438353.12525.513.173.973.63001907.622903147483.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.

ProductTimePriceAdd_spendStore_trafficLog_inventoryCompetitor_priceComp._promoPrice_X_PromoAdd_X_PriceStore_sizeCust_demo
1439313.55490.122.784.053.45001650.322903
1439323.62510.443.013.883.5213.621720.1522903
1439333.48475.82.954.13.38001590.2222903

Download sample datasets from GitHub — also works with CSV files.

Code Walkthrough

Step 1: Initialize

Python
import pandas as pd
from datfid import DATFIDClient

client = DATFIDClient(token="your_DATFID_token")

Step 2: Fit the Model

Python
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

Python
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_promotion

Alpha Estimates (Time-Invariant)

Characteristics constant across time — inherent properties of each product.

VariableEstimateT-statInterpretation
Intercept-14,962184.50Baseline revenue level
Store_size+49.891,355.75Each sq-ft of store size adds ~$49.89 to baseline revenue (strongest predictor)
Cust_demo+546.3456.43Each unit increase in customer demographic score adds ~$546 to baseline revenue

Beta Estimates (Time-Varying)

VariableEstimateT-statInterpretation
Competitor_price+5,307.74182.73Higher competitor prices strongly increase own revenue (customers switch)
Add_spend+53.23408.27Each $1 of ad spend adds ~$53 in revenue (excellent ROI)
Log_inventory+219.585.03Higher inventory levels increase revenue
Price-332.5911.57A $1 price increase reduces revenue by ~$333 (price sensitivity)
Competitor_promotion-104.766.98Competitor promotions decrease own revenue by ~$105
Store_traffic-52.851.42Not statistically significant (p=0.15)

Model Performance

0.998
R² Overall
1.000
R² Between
0.976
R² Within
432.26
MAE
296,001
MSE

Try it yourself: Run this exact analysis in the Free Playground — select "Food Beverages" from the sample datasets and click Run Analysis.