Professional Documents
Culture Documents
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module overview
Sections Demonstrations
1. Forecasting overview • Creating a forecast with Amazon
Forecast
2. Processing time series data
3. Using Amazon Forecast Guided Lab
4. Guided lab • Creating a Forecast with Amazon
Forecast
5. Module wrap-up
Knowledge check
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 2
Module objectives
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 3
Module 4: Introducing Forecasting
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Overview of forecasting
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Time series data
Unit Sales Product #21232
Time series data
is captured in
sequence over time
yyyy-mm No day
ss:s Seconds
mm-dd No year
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 9
Time series handling: Missing data
Forward Fill Moving Average
Last known == missing value Avg(previous) == missing value
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 11
Time series handling: Upsampling
yyyy-mm-dd yyyy-mm-dd HH:MM:SS
Reasons to upsample:
• Match different time series
• Irregular time series
• Knowledge of domain
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 12
Time series handling: Smoothing data
outliers
Smoothing function
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 13
Seasonality
• Seasonality frequency
• Hourly, daily, quarterly, yearly
• Spring, summer, fall, winter
• Major holiday sales, winter
holiday season
• Incorporating holidays
1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 14
Time series correlations
• Stationarity
• How stable is the system?
Autocorrelation?
• Does the past inform the future?
• Trends
• Correlation issues
• Autocorrelation
• How points in time are linearly
related
1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 16
Using pandas for time series data
• Time-aware index
dataframe['2010-01-04']
dataframe['2010-02':'2010-03']
dataframe['weekday_name'] = dataframe.index.weekday_name
• Autocorrelation
dataframe['Quantity'].autocorr()
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 17
Time series algorithms
• Prophet Algorithm
NPTS ETS
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 18
• Time series data is sequenced
Section 2 key
• Time challenges –
takeaways • Different formats
• Missing data
• Seasonality
• Correlations
• The pandas library offers support for
time series data
• With Amazon Forecast, you can
choose between five algorithms
19 © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module 4: Introducing Forecasting
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Forecast workflow
New data, retraining Deploy
model
Business problem
Generate forecasts
Problem Tune Yes
formulation model
Meets
Collect and Evaluate Feature Select and Evaluate
business
label data data engineering train model model
goal?
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 21
Amazon Forecast overview
AWS Management
Historical data Console
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 22
Supported domains
Amazon Forecast
Training Domain-specific
Predictor
data schema
Forecast
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 23
Retail forecasting example
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 25
Selecting an Amazon Forecast algorithm
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 26
Evaluating your forecast: Back testing
Training
Testing
Time
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 27
Evaluation metrics: wQuantileLoss
60
Demand
P10 forecast
40
P50 forecast
P90 forecast 20
-20
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 28
Root mean square error (RMSE)
RMSE is the square of the errors.
Actual
Test Results Test result Prediction Deltas
1 2 4 2
Error is the Actual result Prediction
2 4 8 4
30 difference 3 8 12 4
between the 28 4 16 28 12
25 actual
target value and RMSE 6.708204
20 the forecasted
value 16
15
12
10
8 8 Works best for a
5 model where most
4 4
2 errors are of similar
0 size
1 2 3 4
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 29
Model accuracy example
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 30
Demonstration:
Creating a forecast
with Amazon
Forecast
31 © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• You can use Amazon Forecast for
Section 3 key time series data
takeaways • Schemas are specific for domains
• Data can include –
• Time series data
• Metadata
• Related data
• Data is split into training and testing
data by accounting for time
• Use RMSE and wQuantileLoss
metrics to evaluate model
32 © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module 4 –
Guided Lab:
Creating a Forecast
with Amazon
Forecast
33 © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module 4: Introducing Forecasting
Module wrap-up
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module summary
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 35
Complete the knowledge check
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 36
Additional resources
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 37
Thank you
© 2021 Amazon Web Services, Inc. or its affiliates. All rights reserved. This work may not be reproduced or redistributed, in whole or in part, without prior written permission from Amazon
Web Services, Inc. Commercial copying, lending, or selling is prohibited. Corrections, feedback, or other questions? Contact us at https://support.aws.amazon.com/#/contacts/aws-training.
All trademarks are the property of their owners.