Conduct what-if analyses with Amazon Forecast, up to 80% faster than before
Now with Amazon Forecast, you can seamlessly conduct what-if analyses up to 80% faster to analyze and quantify the potential impact of business levers on your demand forecasts. Forecast is a service that uses machine learning (ML) to generate accurate demand forecasts, without requiring any ML experience. Simulating scenarios through what-if analyses is a powerful business tool to navigate through the uncertainty of future events by capturing possible outcomes from hypothetical scenarios. It’s a common practice to assess the impact of business decisions on revenue or profitability, quantify the risk associated with market trends, evaluate how to organize logistics and workforce to meet customer demand, and much more.
Conducting a what-if analysis for demand forecasting can be challenging because you first need accurate models to forecast demand and then a quick and easy way to reproduce the forecast across a range of scenarios. Until now, although Forecast provided accurate demand forecasts, conducting what-if analysis using Forecast could be cumbersome and time-consuming. For example, retail promotion planning is a common application of what-if analysis to identify the optimal price point for a product to maximize the revenue. Previously on Forecast, you had to prepare and import a new input file for each scenario you wanted to test. If you wanted to test three different price points, you first had to create three new input files by manually transforming the data offline and then importing each file into Forecast separately. In effect, you were doing the same set of tasks for each and every scenario. Additionally, to compare scenarios, you had to download the prediction from each scenario individually and then merge them offline.
With today’s launch, you can easily conduct what-if analysis up to 80% faster. We have made it easy to create new scenarios by removing the need for offline data manipulation and import for each scenario. Now, you can define a scenario by transforming your initial dataset through simple operations, such as multiplying the price for product A by 90% or decreasing the price for product B by $10. These transformations can also be combined with conditions to control the parameters that the scenario applies in (for example, reducing product A’s price in one location only). With this launch, you can define and run multiple scenarios of the same type of analysis (such as promotion analysis) or different types of analyses (such as promotion analysis in geographical region 1 and inventory planning in geographical region 2) simultaneously. Lastly, you no longer need to merge and compare results of scenarios offline. Now, you can view the forecast predictions across all scenarios in the same graph or bulk export the data for offline review.
Solution overview
The steps in this post demonstrate how to use what-if analysis on the AWS Management Console. To directly use Forecast APIs for what-if analysis, follow the notebook in our GitHub repo that provides an analogous demonstration.
Import your training data
To conduct a what-if analysis, you must import two CSV files representing the target time series data (showing the prediction target) and the related time series data (showing attributes that impact the target). Our example target time series file contains the product item ID, timestamp, demand, store ID, city, and region, and our related time series file contains the product item ID, store ID, timestamp, city, region, and price.
To import your data, complete the following steps:
- On the Forecast console, choose View dataset groups.
- Choose Create dataset group.
- For Dataset group name, enter a dataset name (for this post,
my_company_consumer_sales_history
). - For Forecasting domain, choose a forecasting domain (for this post,
Retail
). - Choose Next.
- On the Create target time series dataset page, provide the dataset name, frequency of your data, and data schema
- Provide the dataset import details.
- Choose Start.
The following screenshot shows the information for the target time series page filled out for our example.
You will be taken to the dashboard that you can use to track progress.
- To import the related time series file, on the dashboard, choose Import.
- On the Create related time series dataset page, provide the dataset name and data schema.
- Provide the dataset import details.
- Choose Start.
The following screenshot shows the information filled out for our example.
Train a predictor
Next, we train a predictor.
- On the dashboard, choose Train predictor.
- On the Train predictor page, enter a name for your predictor, how long in the future you want to forecast and at what frequency, and the number of quantiles you want to forecast for.
- Enable AutoPredictor – this is required to use what-if analysis.
- Choose Create.
The following screenshot shows the information filled out for our example.
Create a forecast
After our predictor is trained (this can take approximately 2.5 hours), we create a forecast. You will know that your predictor is trained when you see the View Predictors button on your dashboard.
- Choose Create a forecast on the Dashboard
- On the Create a forecast page, enter a forecast name, choose the predictor that you created, and specify the forecast quantiles (optional) and the items to generate a forecast for.
- Choose Start.
After you complete these steps, you have successfully created a forecast. This represents your baseline forecast scenario that you use to do what-if analyses on.
If you need more help creating your baseline forecasts, refer to Getting Started (Console). We now move to the next steps of conducting a what-if analysis.
Create a what-if analysis
At this point, we have created our baseline forecast and will start the walkthrough of how to conduct a what-if analysis. There are three stages to conducting a what-if analysis: setting up the analysis, creating the what-if forecast by defining what is changed in the scenario, and comparing the results.
- To set up your analysis, choose Explore what-if analysis on the dashboard.
- Choose Create.
- Enter a unique name and select the baseline forecast on the drop-down menu.
- Choose the items in your dataset you want to conduct a what-if analysis for. You have two options:
- Select all items is the default, which we choose in this post.
- If you want to pick specific items, choose Select items with a file and import a CSV file containing the unique identifier for the corresponding item and any associated dimension (such as region).
- Choose Create what-if analysis.
Create a what-if forecast
Next, we create a what-if forecast to define the scenario we want to analyze.
- Choose Create.
- Enter a name of your scenario.
You can define your scenario through two options:
- Use transformation functions – Use the transformation builder to transform the related time series data you imported. For this walkthrough, we evaluate how the demand an item in our dataset changes when the price is reduced by 10% and then by 30% when compared to the price in the baseline forecast.
- Define the what-if forecast with a replacement dataset – Replace the related time series dataset you imported.
The transformation function builder provides the capability to transform the related time series data you imported earlier through simple operations to add, subtract, divide, and multiply features in your data (for example price) by a value you specify. For our example, we create a scenario where we reduce the price by 10%, and price is a feature in the dataset.
- For What-if forecast definition method, select Use transformation functions.
- Choose Multiply as our operator, price as our time series, and enter 0.9.
You can also add conditions to further refine your scenario. For example if your dataset contained store information organized by region, you could limit the price reduction scenario by region. You could define a scenario of a 10% price reduction that’s applicable to stores not in Region_1.
- Choose Add condition.
- Choose Not equals as the operation and enter Region_1.
Another option to modify your related time series is by importing a new dataset that already contains the data defining the scenario. For example, to define a scenario with 10% price reduction, we can upload a new dataset specifying the unique identifier for the items that are changing and the price change that is 10% lower. To do so, select Define the what-if forecast with a replacement dataset and import a CSV containing the price change.
- To complete the what-if forecast definition, choose Create.
Repeat the process to create another what-if forecast with a 30% price reduction.
After the what-if analysis has run for each what-if forecast, the status will change to active. This concludes the second stage, and you can move on to comparing the what-if forecasts.
Compare the forecasts
We can now compare the what-if forecasts for both our scenarios, comparing a 10% price reduction with a 30% price reduction.
- On the analysis insights page, navigate to the Compare what-if forecasts section.
- For item_id, enter the item to analyze.
- For What-if forecasts, choose the scenarios to compare (for this post,
Scenario_1
andScenario_2
). - Choose Compare what-if.
The following graph shows the resulting demand in both our scenarios.
By default, it showcases the P50 and the base case scenario. You can view all quantiles generated by selecting your preferred quantiles on the Choose forecasts drop-down menu.
Export your data
To export your data to CSV, complete the following steps:
- Choose Create export.
- Enter a name for your export file (for this post,
my_scenario_export
) - Specify the scenarios to be exported by selecting the scenarios on the What-If Forecast drop-down menu. You can export multiple scenarios at once in a combined file.
- For Export location, specify the Amazon Simple Storage Service (Amazon S3) location.
- To begin the export, choose Create Export.
- To download the export, first navigate to S3 file path location from the AWS Management Console and the select the file and choose the download button. The export file will contain the timestamp, item ID, dimensions, and the forecasts for each quantile for all scenarios selected (including the base scenario).
Conclusion
Scenario analysis is a critical tool to help navigate through the uncertainties of business. It provides foresight and a mechanism to stress-test ideas, leaving businesses more resilient, better prepared, and in control of their future. Forecast now supports forecasting what-if scenario analyses. To conduct your scenario analysis, open the Forecast console and follow the steps outlined in this post, or refer to our GitHub notebook on how to access the functionality via API.
To learn more, refer to the CreateWhatIfAnalysis page in the developer guide.
About the authors
Brandon Nair is a Sr. Product Manager for Amazon Forecast. His professional interest lies in creating scalable machine learning services and applications. Outside of work he can be found exploring national parks, perfecting his golf swing or planning an adventure trip.
Akhil Raj Azhikodan is a Software Development Engineer working on Amazon Forecast. His interests are in designing and building reliable systems that solve complex customer problems. Outside of work, he enjoys learning about history, hiking and playing video games.
Conner Smith is a Software Development Engineer working on Amazon Forecast. He focuses on building secure, scalable distributed systems that provide value to customers. Outside of work he spends time reading fiction, playing guitar, and watching random YouTube videos.
Shannon Killingsworth is the UX Designer for Amazon Forecast. He has been improving the user experience in Forecast for two years by simplifying processes as well as adding new features in ways that make sense to our users. Outside of work he enjoys running, drawing, and reading.
Tags: Archive
Leave a Reply