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*Store_size + α3*Cust_demo + β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,962.3184.5Baseline revenue offset (large negative because the model centres on store and demographic effects).
Store_size+49.91,355.8Each unit of store size adds ~49.9 to revenue.
Cust_demo+546.356.4Each step up in customer-demographics index adds ~546.3 to revenue.

Beta Estimates (Time-Varying)

VariableEstimateT-statInterpretation
Price-332.611.6Each $1 increase in price subtracts ~332.6 in revenue — the headline elasticity.
Add_spend+53.2408.3Each $1 of advertising spend lifts revenue by ~53.2 — strong ROAS.
Store_traffic-52.91.4Foot traffic moves revenue slightly down in this run, but the effect is not statistically significant.
Log_inventory+219.65.0A 1-unit increase in log inventory adds ~219.6 to revenue.
Competitor_price+5,307.7182.7Each $1 a competitor raises their price adds ~5,307.7 to our revenue — strong cross-elasticity.
Competitor_promotion-104.87.0A 1-unit increase in competitor promotion subtracts ~104.8 from revenue.

Model Performance

0.998
R² Overall
1.000
R² Between
0.976
R² Within
432.3
MAE
296,001.0
MSE

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