Documentation Index
Fetch the complete documentation index at: https://nixtla-docs-broken-links-fix.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
TimeGPT makes it possible to forecast product demand in the retail sector and evaluate how different pricing scenarios might affect demand. Scenario analysis offers valuable insights for informed decision-making.
Forecast product demand using price as an exogenous variable
Evaluate different pricing scenarios
1. Import required packages
Import the packages needed for this tutorial and initialize your Nixtla client:
- Standard Endpoint
- Azure AI Endpoint
If you are using Nixtla’s standard endpoint, simply provide your API key:
Initialize NixtlaClient with Standard Endpoint
2. Load the M5 dataset
We will use the M5 dataset, containing product sales data from 10 US retail stores. The data includes:
Because we want price-driven demand forecasts, we’ll focus on the
| DataFrame | Contents |
|---|---|
Y_df | Historical sales (y) for each product (unique_id) and date (ds). |
X_df | Additional information (exogenous variables) such as sell_price. |
For a full tutorial on incorporating exogenous variables with TimeGPT, please see the dedicated documentation.
sell_price column:3. Forecast demand using price as an exogenous variable
In this example, we forecast for a single product (Merge the sales (Check the historical demand and pricing trends:Now, split the data into:
• Training data (Generate forecasts using TimeGPT (28 days ahead):Finally, visualize your baseline forecast:
FOODS_1_129_) across all 10 stores. This product exhibits frequent price changes, making it ideal for modeling price effects on demand.y) and price (sell_price) data into one DataFrame:df_train)
• Future exogenous data (future_ex_vars_df)When using Azure AI endpoints, specify
model="azureai" in the forecast call. Refer to the official tutorials for more details.4. 'What if?' forecasting: exploring price changes
We’ll now explore ±5% price changes and their impact on demand. Adjust future prices, forecast demand, and compare to the baseline:Rename and combine the scenario forecasts:Visualize all three forecasts (baseline, +5%, and –5%):
What is Price Elasticity?
What is Price Elasticity?
Price elasticity measures demand sensitivity to price changes. For more details, see this
Wikipedia article.
Important Considerations
Important Considerations