Uploaded by evren.tuerkday

11 Classical Time Series Forecasting Methods

advertisement
Click to Take the FREE Time Series Crash-Course

Search...
Get Started
Blog
Topics 
EBooks
FAQ
About
Contact
11 Classical Time Series Forecasting Methods
in Python (Cheat Sheet)
by Jason Brownlee on August 6, 2018 in Time Series
Tweet
Share
Welcome!
I'm Jason Brownlee PhD
and I help developers get results
with machine learning.
Read more
Share
Last Updated on December 10, 2020
Never miss a tutorial:
Machine learning methods can be used for classification and forecasting on time series
problems.
Before exploring machine learning methods for time series, it is a good idea to ensure you
have exhausted classical linear time series forecasting methods. Classical time series
forecasting methods may be focused on linear relationships, nevertheless, they are
sophisticated and perform well on a wide range of problems, assuming that your data is
suitably prepared and the method is well configured.
In this post, will you will discover a suite of classical methods for time series forecasting
that you can test on your forecasting problem prior to exploring to machine learning methods.
Picked for you:
How to Create an ARIMA Model for Time
Series Forecasting in Python
How to Convert a Time Series to a
Supervised Learning Problem in Python
The post is structured as a cheat sheet to give you just enough information on each method
to get started with a working code example and where to look to get more information on the
method.
11 Classical Time Series Forecasting
Methods in Python (Cheat Sheet)
All code examples are in Python and use the Statsmodels library. The APIs for this library can
be tricky for beginners (trust me!), so having a working code example as a starting point will
greatly accelerate your progress.
How To Backtest Machine Learning
Models for Time Series Forecasting
This is a large post; you may want to bookmark it.
Time Series Forecasting as Supervised
Learning
Start Machine Learning
Kick-start your project with my new book Time Series Forecasting With Python, including
step-by-step tutorials and the Python source code files for all examples.
Let’s get started.
Updated Apr/2020: Changed AR to AutoReg due to API change.
Updated Dec/2020: Updated ARIMA API to the latest version of statsmodels.
Loving the Tutorials?
The Time Series with Python EBook is
where you'll find the Really Good stuff.
>> SEE WHAT'S INSIDE
Start Machine Learning
You can master applied Machine Learning
without math or fancy degrees.
Find out how in this free and practical course.
Email Address
I consent to receive information about
services and special offers by email. For more
information, see the Privacy Policy.
START MY EMAIL COURSE
11 Classical Time Series Forecasting Methods in Python (Cheat Sheet)
Photo by Ron Reiring, some rights reserved.
Overview
This cheat sheet demonstrates 11 different classical time series forecasting methods; they
are:
1. Autoregression (AR)
2. Moving Average (MA)
3. Autoregressive Moving Average (ARMA)
4. Autoregressive Integrated Moving Average (ARIMA)
5. Seasonal Autoregressive Integrated Moving-Average (SARIMA)
×
6. Seasonal Autoregressive Integrated Moving-Average with Exogenous Regressors
(SARIMAX)
7. Vector Autoregression (VAR)
8. Vector Autoregression Moving-Average (VARMA)
9. Vector Autoregression Moving-Average with Exogenous Regressors (VARMAX)
10. Simple Exponential Smoothing (SES)
11. Holt Winter’s Exponential Smoothing (HWES)
Did I miss your favorite classical time series forecasting method?
Let me know in the comments below.
Each method is presented in a consistent manner.
This includes:
Description. A short and precise description of the technique.
Python Code. A short working example of fitting the model and making a prediction in
Python.
More Information. References for the API and the algorithm.
Each code example is demonstrated on a simple contrived dataset that may or may not be
appropriate for the method. Replace the contrived dataset with your data in order to test the
method.
Remember: each method will require tuning to your specific problem. In many cases, I have
examples of how to configure and even grid search parameters on the blog already, try the
search function.
If you find this cheat sheet useful, please let me know in the comments below.
Autoregression (AR)
The autoregression (AR) method models the next step in the sequence as a linear function of
the observations at prior time steps.
The notation for the model involves specifying the order of the model p as a parameter to the
AR function, e.g. AR(p). For example, AR(1) is a first-order autoregression model.
The method is suitable for univariate time series without trend and seasonal components.
Python Code
1
2
3
4
5
6
7
8
9
10
11
# AR example
from statsmodels.tsa.ar_model import AutoReg
from random import random
# contrived dataset
data = [x + random() for x in range(1, 100)]
# fit model
model = AutoReg(data, lags=1)
model_fit = model.fit()
# make prediction
yhat = model_fit.predict(len(data), len(data))
print(yhat)
More Information
statsmodels.tsa.ar_model.AutoReg API
statsmodels.tsa.ar_model.AutoRegResults API
Autoregressive model on Wikipedia
Moving Average (MA)
The moving average (MA) method models the next step in the sequence as a linear function
of the residual errors from a mean process at prior time steps.
A moving average model is different from calculating the moving average of the time series.
The notation for the model involves specifying the order of the model q as a parameter to the
MA function, e.g. MA(q). For example, MA(1) is a first-order moving average model.
The method is suitable for univariate time series without trend and seasonal components.
Python Code
We can use the ARIMA class to create an MA model and setting a zeroth-order AR model.
We must specify the order of the MA model in the order argument.
1
2
3
4
5
6
# MA example
from statsmodels.tsa.arima.model import ARIMA
from random import random
# contrived dataset
data = [x + random() for x in range(1, 100)]
# fit model
7
8
9
10
11
model = ARIMA(data, order=(0, 0, 1))
model_fit = model.fit()
# make prediction
yhat = model_fit.predict(len(data), len(data))
print(yhat)
More Information
Moving-average model on Wikipedia
Autoregressive Moving Average (ARMA)
The Autoregressive Moving Average (ARMA) method models the next step in the sequence
as a linear function of the observations and residual errors at prior time steps.
It combines both Autoregression (AR) and Moving Average (MA) models.
The notation for the model involves specifying the order for the AR(p) and MA(q) models as
parameters to an ARMA function, e.g. ARMA(p, q). An ARIMA model can be used to develop
AR or MA models.
The method is suitable for univariate time series without trend and seasonal components.
Python Code
1
2
3
4
5
6
7
8
9
10
11
# ARMA example
from statsmodels.tsa.arima.model import ARIMA
from random import random
# contrived dataset
data = [random() for x in range(1, 100)]
# fit model
model = ARIMA(data, order=(2, 0, 1))
model_fit = model.fit()
# make prediction
yhat = model_fit.predict(len(data), len(data))
print(yhat)
More Information
Autoregressive–moving-average model on Wikipedia
Autoregressive Integrated Moving Average (ARIMA)
The Autoregressive Integrated Moving Average (ARIMA) method models the next step in the
sequence as a linear function of the differenced observations and residual errors at prior time
steps.
It combines both Autoregression (AR) and Moving Average (MA) models as well as a
differencing pre-processing step of the sequence to make the sequence stationary, called
integration (I).
The notation for the model involves specifying the order for the AR(p), I(d), and MA(q) models
as parameters to an ARIMA function, e.g. ARIMA(p, d, q). An ARIMA model can also be used
to develop AR, MA, and ARMA models.
The method is suitable for univariate time series with trend and without seasonal components.
Python Code
1
2
3
4
5
6
7
8
9
10
11
# ARIMA example
from statsmodels.tsa.arima.model import ARIMA
from random import random
# contrived dataset
data = [x + random() for x in range(1, 100)]
# fit model
model = ARIMA(data, order=(1, 1, 1))
model_fit = model.fit()
# make prediction
yhat = model_fit.predict(len(data), len(data), typ='levels')
print(yhat)
More Information
Autoregressive integrated moving average on Wikipedia
Seasonal Autoregressive Integrated Moving-Average
(SARIMA)
The Seasonal Autoregressive Integrated Moving Average (SARIMA) method models the next
step in the sequence as a linear function of the differenced observations, errors, differenced
seasonal observations, and seasonal errors at prior time steps.
It combines the ARIMA model with the ability to perform the same autoregression,
differencing, and moving average modeling at the seasonal level.
The notation for the model involves specifying the order for the AR(p), I(d), and MA(q) models
as parameters to an ARIMA function and AR(P), I(D), MA(Q) and m parameters at the
seasonal level, e.g. SARIMA(p, d, q)(P, D, Q)m where “m” is the number of time steps in each
season (the seasonal period). A SARIMA model can be used to develop AR, MA, ARMA and
ARIMA models.
The method is suitable for univariate time series with trend and/or seasonal components.
Python Code
1
2
3
4
5
6
7
8
9
10
11
# SARIMA example
from statsmodels.tsa.statespace.sarimax import SARIMAX
from random import random
# contrived dataset
data = [x + random() for x in range(1, 100)]
# fit model
model = SARIMAX(data, order=(1, 1, 1), seasonal_order=(0, 0, 0, 0))
model_fit = model.fit(disp=False)
# make prediction
yhat = model_fit.predict(len(data), len(data))
print(yhat)
More Information
statsmodels.tsa.statespace.sarimax.SARIMAX API
statsmodels.tsa.statespace.sarimax.SARIMAXResults API
Autoregressive integrated moving average on Wikipedia
Seasonal Autoregressive Integrated Moving-Average
with Exogenous Regressors (SARIMAX)
The Seasonal Autoregressive Integrated Moving-Average with Exogenous Regressors
(SARIMAX) is an extension of the SARIMA model that also includes the modeling of
exogenous variables.
Exogenous variables are also called covariates and can be thought of as parallel input
sequences that have observations at the same time steps as the original series. The primary
series may be referred to as endogenous data to contrast it from the exogenous sequence(s).
The observations for exogenous variables are included in the model directly at each time step
and are not modeled in the same way as the primary endogenous sequence (e.g. as an AR,
MA, etc. process).
The SARIMAX method can also be used to model the subsumed models with exogenous
variables, such as ARX, MAX, ARMAX, and ARIMAX.
The method is suitable for univariate time series with trend and/or seasonal components and
exogenous variables.
Python Code
1
2
3
4
5
6
7
8
9
10
11
12
13
# SARIMAX example
from statsmodels.tsa.statespace.sarimax import SARIMAX
from random import random
# contrived dataset
data1 = [x + random() for x in range(1, 100)]
data2 = [x + random() for x in range(101, 200)]
# fit model
model = SARIMAX(data1, exog=data2, order=(1, 1, 1), seasonal_order=(0, 0, 0, 0))
model_fit = model.fit(disp=False)
# make prediction
exog2 = [200 + random()]
yhat = model_fit.predict(len(data1), len(data1), exog=[exog2])
print(yhat)
More Information
statsmodels.tsa.statespace.sarimax.SARIMAX API
statsmodels.tsa.statespace.sarimax.SARIMAXResults API
Autoregressive integrated moving average on Wikipedia
Vector Autoregression (VAR)
The Vector Autoregression (VAR) method models the next step in each time series using an
AR model. It is the generalization of AR to multiple parallel time series, e.g. multivariate time
series.
The notation for the model involves specifying the order for the AR(p) model as parameters to
a VAR function, e.g. VAR(p).
The method is suitable for multivariate time series without trend and seasonal components.
Python Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# VAR example
from statsmodels.tsa.vector_ar.var_model import VAR
from random import random
# contrived dataset with dependency
data = list()
for i in range(100):
v1 = i + random()
v2 = v1 + random()
row = [v1, v2]
data.append(row)
# fit model
model = VAR(data)
model_fit = model.fit()
# make prediction
yhat = model_fit.forecast(model_fit.y, steps=1)
print(yhat)
More Information
statsmodels.tsa.vector_ar.var_model.VAR API
statsmodels.tsa.vector_ar.var_model.VARResults API
Vector autoregression on Wikipedia
Vector Autoregression Moving-Average (VARMA)
The Vector Autoregression Moving-Average (VARMA) method models the next step in each
time series using an ARMA model. It is the generalization of ARMA to multiple parallel time
series, e.g. multivariate time series.
The notation for the model involves specifying the order for the AR(p) and MA(q) models as
parameters to a VARMA function, e.g. VARMA(p, q). A VARMA model can also be used to
develop VAR or VMA models.
The method is suitable for multivariate time series without trend and seasonal components.
Python Code
1
2
3
4
# VARMA example
from statsmodels.tsa.statespace.varmax import VARMAX
from random import random
# contrived dataset with dependency
5
6
7
8
9
10
11
12
13
14
15
16
data = list()
for i in range(100):
v1 = random()
v2 = v1 + random()
row = [v1, v2]
data.append(row)
# fit model
model = VARMAX(data, order=(1, 1))
model_fit = model.fit(disp=False)
# make prediction
yhat = model_fit.forecast()
print(yhat)
More Information
statsmodels.tsa.statespace.varmax.VARMAX API
statsmodels.tsa.statespace.varmax.VARMAXResults
Vector autoregression on Wikipedia
Vector Autoregression Moving-Average with
Exogenous Regressors (VARMAX)
The Vector Autoregression Moving-Average with Exogenous Regressors (VARMAX) is an
extension of the VARMA model that also includes the modeling of exogenous variables. It is a
multivariate version of the ARMAX method.
Exogenous variables are also called covariates and can be thought of as parallel input
sequences that have observations at the same time steps as the original series. The primary
series(es) are referred to as endogenous data to contrast it from the exogenous sequence(s).
The observations for exogenous variables are included in the model directly at each time step
and are not modeled in the same way as the primary endogenous sequence (e.g. as an AR,
MA, etc. process).
The VARMAX method can also be used to model the subsumed models with exogenous
variables, such as VARX and VMAX.
The method is suitable for multivariate time series without trend and seasonal components
with exogenous variables.
Python Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# VARMAX example
from statsmodels.tsa.statespace.varmax import VARMAX
from random import random
# contrived dataset with dependency
data = list()
for i in range(100):
v1 = random()
v2 = v1 + random()
row = [v1, v2]
data.append(row)
data_exog = [x + random() for x in range(100)]
# fit model
model = VARMAX(data, exog=data_exog, order=(1, 1))
model_fit = model.fit(disp=False)
# make prediction
data_exog2 = [[100]]
yhat = model_fit.forecast(exog=data_exog2)
print(yhat)
More Information
statsmodels.tsa.statespace.varmax.VARMAX API
statsmodels.tsa.statespace.varmax.VARMAXResults
Vector autoregression on Wikipedia
Simple Exponential Smoothing (SES)
The Simple Exponential Smoothing (SES) method models the next time step as an
exponentially weighted linear function of observations at prior time steps.
The method is suitable for univariate time series without trend and seasonal components.
Python Code
1
2
3
4
5
6
7
8
9
10
11
# SES example
from statsmodels.tsa.holtwinters import SimpleExpSmoothing
from random import random
# contrived dataset
data = [x + random() for x in range(1, 100)]
# fit model
model = SimpleExpSmoothing(data)
model_fit = model.fit()
# make prediction
yhat = model_fit.predict(len(data), len(data))
print(yhat)
More Information
statsmodels.tsa.holtwinters.SimpleExpSmoothing API
statsmodels.tsa.holtwinters.HoltWintersResults API
Exponential smoothing on Wikipedia
Holt Winter’s Exponential Smoothing (HWES)
The Holt Winter’s Exponential Smoothing (HWES) also called the Triple Exponential
Smoothing method models the next time step as an exponentially weighted linear function of
observations at prior time steps, taking trends and seasonality into account.
The method is suitable for univariate time series with trend and/or seasonal components.
Python Code
1
2
3
4
5
6
7
8
9
10
11
# HWES example
from statsmodels.tsa.holtwinters import ExponentialSmoothing
from random import random
# contrived dataset
data = [x + random() for x in range(1, 100)]
# fit model
model = ExponentialSmoothing(data)
model_fit = model.fit()
# make prediction
yhat = model_fit.predict(len(data), len(data))
print(yhat)
More Information
statsmodels.tsa.holtwinters.ExponentialSmoothing API
statsmodels.tsa.holtwinters.HoltWintersResults API
Exponential smoothing on Wikipedia
Further Reading
This section provides more resources on the topic if you are looking to go deeper.
Statsmodels: Time Series analysis API
Statsmodels: Time Series Analysis by State Space Methods
Summary
In this post, you discovered a suite of classical time series forecasting methods that you can
test and tune on your time series dataset.
Did I miss your favorite classical time series forecasting method?
Let me know in the comments below.
Did you try any of these methods on your dataset?
Let me know about your findings in the comments.
Do you have any questions?
Ask your questions in the comments below and I will do my best to answer.
Want to Develop Time Series Forecasts with Python?
Develop Your Own Forecasts in Minutes
...with just a few lines of python code
Discover how in my new Ebook:
Introduction to Time Series Forecasting With Python
It covers self-study tutorials and end-to-end projects on topics
like: Loading data, visualization, modeling, algorithm tuning, and
much more...
Finally Bring Time Series Forecasting to
Your Own Projects
Skip the Academics. Just Results.
SEE WHAT'S INSIDE
Tweet
Share
Share
About Jason Brownlee
Jason Brownlee, PhD is a machine learning specialist who teaches developers how to
get results with modern machine learning methods via hands-on tutorials.
View all posts by Jason Brownlee →
 Statistics for Machine Learning (7-Day Mini-Course)
Taxonomy of Time Series Forecasting Problems 
335 Responses to 11 Classical Time Series Forecasting Methods in
Python (Cheat Sheet)
Adriena Welch August 6, 2018 at 3:20 pm #
REPLY 
Hi Jason, thanks for such an excellent and comprehensive post on time series. I
sincerely appreciate your effort. As you ask for the further topic, just wondering if I can request
you for a specific topic I have been struggling to get an output. It’s about Structural Dynamic
Factor model ( SDFM) by Barigozzi, M., Conti, A., and Luciani, M. (Do euro area countries
respond asymmetrically to the common monetary policy) and Mario Forni Luca Gambetti (The
Dynamic Effects of Monetary Policy: A Structural Factor Model Approach). Would it be
possible for you to go over and estimate these two models using Python or R? It’s just a
request from me and sorry if it doesn’t go with your interest.
Jason Brownlee August 7, 2018 at 6:23 am #
REPLY 
Thanks for the suggestion. I’ve not heard of that method before.
Akhila March 10, 2020 at 7:17 pm #
REPLY 
I have 1000 time series data and i want to predict next 500 steps. So how
can i do this
Jason Brownlee March 11, 2020 at 5:22 am #
REPLY 
Fit a model then call the predict() function.
Abhi April 8, 2020 at 8:20 pm #
Hi Jason can the above mentioned algorithms can be used for
Demand forecast ing as well?
Jason Brownlee April 9, 2020 at 8:00 am #
I don’t see why not.
Abhishek May 8, 2020 at 8:15 am #
Hi Jason,
Great technical insights. I work in the oil and gas sector and one of our day to
day job is to to rate vs time oil rate forecasting. We typically use empirical
equations and use regression to fit those empirical input parameters. I was
wondering if we could use sophisticated ML techniques to accomplish this?
Thanks!
Jason Brownlee May 8, 2020 at 11:20 am #
Thanks.
Yes, perhaps start with the examples here:
https://machinelearningmastery.com/start-here/#deep_learning_time_series
Greg June 15, 2020 at 11:17 pm #
Hello Jason, thanks for your great work.
Can you give an example on how to fit a model and use of predict() function?
Jason Brownlee June 16, 2020 at 5:40 am #
Yes, see this:
https://machinelearningmastery.com/arima-for-time-series-forecasting-withpython/
Dr.Vaibhav August 11, 2020 at 12:54 am #
REPLY 
Thanks for sharing
Dali July 26, 2020 at 12:06 am #
REPLY 
#Abhishek I work in oil&gas company too, and I tried to generate forecasts using
ML. the problem is that you can’t relay only on prodaction rates, some parameters should
be included in the model such as WHFP, BHFP, SEP P, WC… for all wells to accurately
estimate the total production. An other problem is that even you came somehow to collect
those data you cannot relay on them because generally those data are daily averages
and dont reflect the variations in real time. Also, prodaction rates for each well are
genarelly calculated using allocation method.
Kamal Singh August 6, 2018 at 6:19 pm #
REPLY 
I am working on Time series or Prediction with neural network and SVR, I want to this
in matlab by scratch can you give me the references of this materials
Thank you in advance
Jason Brownlee August 7, 2018 at 6:26 am #
REPLY 
Sorry, I don’t have any materials for matlab, it is only really used in universities.
Jason August 18, 2020 at 7:52 pm #
REPLY 
not true, but ok
Jason Brownlee August 19, 2020 at 5:59 am #
REPLY 
Fair enough.
The demand for “python machine learning” is orders of magnitude higher than
“matlab machine learning”, this drives my focus:
https://trends.google.com/trends/explore?date=today%205y&q=python%20machine%20learning,matlab%20machine%20learning
Catalin August 6, 2018 at 8:50 pm #
REPLY 
Hi Jason! From which editor do you import the python code into the webpage of your
article? Or what kind of container it that windowed control used to display the python code?
Jason Brownlee August 7, 2018 at 6:26 am #
REPLY 
Great question, I explain the software I use for the website here:
https://machinelearningmastery.com/faq/single-faq/what-software-do-you-use-to-run-yourwebsite
Mike August 7, 2018 at 2:28 am #
REPLY 
Thanks for all the things to try!
I recently stumbled over some tasks where the classic algorithms like linear regression or
decision trees outperformed even sophisticated NNs. Especially when boosted or averaged
out with each other.
Maybe its time to try the same with time series forecasting as I’m not getting good results for
some tasks with an LSTM.
Jason Brownlee August 7, 2018 at 6:30 am #
REPLY 
Always start with simple methods before trying more advanced methods.
The complexity of advanced methods just be justified by additional predictive skill.
Elie Kawerk August 7, 2018 at 2:36 am #
REPLY 
Hi Jason,
Thanks for this nice post!
You’ve imported the sin function from math many times but have not used it.
I’d like to see more posts about GARCH, ARCH and co-integration models.
Best,
Elie
Jason Brownlee August 7, 2018 at 6:30 am #
REPLY 
Thanks, fixed.
I have a post on ARCH (and friends) scheduled.
Elie Kawerk August 7, 2018 at 2:38 am #
REPLY 
Will you consider writing a follow-up book on advanced time-series models soon?
Jason Brownlee August 7, 2018 at 6:32 am #
REPLY 
Yes, it is written. I am editing it now. The title will be “Deep Learning for Time
Series Forecasting”.
CNNs are amazing at time series, and CNNs + LSTMs together are really great.
Elie Kawerk August 7, 2018 at 6:40 am #
REPLY 
will the new book cover classical time-series models like VAR, GARCH, ..?
Jason Brownlee August 7, 2018 at 2:29 pm #
REPLY 
The focus is deep learning (MLP, CNN and LSTM) with tutorials on how
to get the most from classical methods (Naive, SARIMA, ETS) before jumping into
deep learning methods. I hope to have it done by the end of the month.
Elie Kawerk August 7, 2018 at 5:02 pm #
This is great news! Don’t you think that R is better suited than
Python for classical time-series models?
Jason Brownlee August 8, 2018 at 6:15 am #
Perhaps generally, but not if you are building a system for
operational use. I think Python is a better fit.
Dark7wind August 9, 2018 at 7:16 am #
Great to hear this news. May I ask if the book also cover the topic of
multivariate and multistep?
Jason Brownlee August 9, 2018 at 7:34 am #
Yes, there are many chapters on multi-step and most chapters work
with multivariate data.
Ger July 6, 2019 at 5:36 pm #
Well, although it is a really helpful and useful book as it is usually
made by Jason, this book does not cover multivariate time series problems, in
fact Jason explicitely says “This is not a treatment of complex time series
problems. It does
not provide tutorials on advanced topics like multi-step sequence forecasts,
multivariate time series problems or spatial-temporal prediction problems.”
Jason Brownlee July 7, 2019 at 7:49 am #
Correct. I cover complex topics in “deep learning for time series
forecasting”.
REPLY 
Søren August 7, 2018 at 10:27 pm #
😉
Sounds amazing that you finally
are geting the new book out on timeseries models – when will it be available to buy?
Jason Brownlee August 8, 2018 at 6:20 am #
Thanks. I hope by the end of the month or soon after.
REPLY 
Kalpesh Ghadigaonkar March 5, 2019 at 1:01 am #
REPLY 
Hi, Can you help me with Arimax ?
Arun Mishra August 10, 2018 at 5:25 am #
REPLY 
I use Prophet.
https://facebook.github.io/prophet/docs/quick_start.html
Also, sometimes FastFourier Transformations gives a good result.
Jason Brownlee August 10, 2018 at 6:21 am #
REPLY 
Thanks.
AJ Rader August 16, 2018 at 7:11 am #
REPLY 
I would second the use of prophet, especially in the context of shock events
— this is where this approach has a unique advantage.
Jason Brownlee August 16, 2018 at 1:56 pm #
REPLY 
Thanks for the suggestion.
Naresh May 4, 2019 at 4:28 pm #
REPLY 
Hi,can you pls help to get the method for timeseries forecasting of10000
products at same time .
Jason Brownlee May 5, 2019 at 6:24 am #
REPLY 
I have some suggestions here that might help (replace “site” with
“product”):
https://machinelearningmastery.com/faq/single-faq/how-to-develop-forecastmodels-for-multiple-sites
User104 May 17, 2019 at 2:24 pm #
REPLY 
Hi Arun,
Can you let me know how you worked with fbprophet. I am struggling with the
installation of fbprophet module. Since it’s asking for c++ complier. Can you please
share how you installed the c++ complier. I tried all ways to resolve it.
Thanks
Jason Brownlee May 17, 2019 at 2:53 pm #
REPLY 
I have not worked with fbprophet, sorry.
TJ Slezak June 5, 2019 at 1:45 am #
REPLY 
conda install gcc
Jason Brownlee June 5, 2019 at 8:47 am #
Nice!
Ravi Rokhade August 10, 2018 at 5:19 pm #
What are the typical application domain of these algos?
REPLY 
Jason Brownlee August 11, 2018 at 6:06 am #
REPLY 
Forecasting a time series across domains.
Alberto Garcia Galindo August 11, 2018 at 12:14 am #
REPLY 
Hi Jason!
Firstly I congratulate you for your blog. It is helping me a lot in my final work on my bachelor’s
degree in Statistics!
What are the assumptions for make forecasting on time series using Machine Learning
algorithms? For example, it must to be stationary? Thanks!
Jason Brownlee August 11, 2018 at 6:11 am #
REPLY 
Gaussian error, but they work anyway if you violate assumptions.
The methods like SARIMA/ETS try to make the series stationary as part of modeling (e.g.
differencing).
You may want to look at power transforms to make data more Gaussian.
sana June 23, 2020 at 6:30 am #
REPLY 
so when using machine learning algorithms there is no need to make data
stationery?
Jason Brownlee June 23, 2020 at 6:33 am #
REPLY 
It depends on the algorithm and the data, yes this is often the case.
Neeraj August 12, 2018 at 4:55 pm #
REPLY 
Hi Jason
I’m interested in forecasting the temperatures
I’m provided with the previous data of the temperature
Can you suggest me the procedure I should follow in order to solve this problem
Jason Brownlee August 13, 2018 at 6:15 am #
REPLY 
Yes, an SARIMA model would be a great place to start.
Den August 16, 2018 at 12:15 am #
REPLY 
Hey Jason,
Cool stuff as always. Kudos to you for making me a ML genius!
Real quick:
How would you combine VARMAX with an SVR in python?
Elaboration.
Right now I am trying to predict a y-value, and have x1…xn variables.
The tricky part is, the rows are grouped.
So, for example.
If the goal is to predict the price of a certain car in the 8th year, and I have data for 1200 cars,
and for each car I have x11_xnm –> y1_xm data (meaning that let’s say car_X has data until
m=10 years and car_X2 has data until m=3 years, for example).
First I divide the data with the 80/20 split, trainset/testset, here the first challenge arises. How
to make the split?? I chose to split the data based on the car name, then for each car I
gathered the data for year 1 to m. (If this approach is wrong, please tell me) The motivation
behind this, is that the 80/20 could otherwise end up with data of all the cars of which some
would have all the years and others would have none of the years. aka a very skewed
distribution.
Then I create a model using an SVR, with some parameters.
And then I try to predict the y-values of a certain car. (value in year m)
However, I do not feel as if I am using the time in my prediction. Therefore, I turned to
VARMAX.
Final question(s).
How do you make a time series prediction if you have multiple groups [in this case 1200 cars,
each of which have a variable number of years(rows)] to make the model from?
Am I doing right by using the VARMAX or could you tell me a better approach?
Sorry for the long question and thank you for your patience!
Best,
Den
Jason Brownlee August 16, 2018 at 6:09 am #
REPLY 
You can try model per group or across groups. Try both and see what works
best.
Compare a suite of ml methods to varmax and use what performs the best on your
dataset.
Petrônio Cândido August 16, 2018 at 6:36 am #
REPLY 
Hi Jason!
Excellent post! I also would like to invite you to know the Fuzzy Time Series, which are data
driven, scalable and interpretable methods to analyze and forecast time series data. I have
recently published a python library for that on http://petroniocandido.github.io/pyFTS/ .
All feedbacks are welcome! Thanks in advance!
Jason Brownlee August 16, 2018 at 1:55 pm #
Thanks for sharing.
REPLY 
SuFian AhMad May 15, 2019 at 3:43 pm #
REPLY 
Hello Sir, Can you please share an example code using your Fuzzy Logic
timeseries library..
I want to implement Fuzzy Logic time series, and i am just a student, so that’s why it will
be a great help from you if you will help me in this.
I just need a sample code that is written in python.
Chris Phillips August 30, 2018 at 8:19 am #
REPLY 
Hi Jason,
Thank you so much for the many code examples on your site. I am wondering if you can help
an amatur like me on something.
When I pull data from our database, I generally do it for multiple SKU’s at the same time into a
large table. Considering that there are thousands of unique SKU’s in the table, is there a
methodology you would recommend for generating a forecast for each individual SKU? My
initial thought is to run a loop and say something to the effect of: For each in SKU run…Then
the VAR Code or the SARIMA code.
Ideally I’d love to use SARIMA, as I think this works the best for the data I am looking to
forecast, but if that is only available to one SKU at a time and VAR is not constrained by this, it
will work as well. If there is a better methodology that you know of for these, I would gladly
take this advice as well!
Thank you so much!
Jason Brownlee August 30, 2018 at 4:49 pm #
REPLY 
Yes, I’d encourage you to use this methodology:
https://machinelearningmastery.com/how-to-develop-a-skilful-time-series-forecastingmodel/
Eric September 6, 2018 at 6:32 am #
REPLY 
Great post. I’m currently investigating a state space approach to forecasting.
Dynamic Linear Modeling using a Kálmán Filter algorithm (West, Hamilton). There is a python
package, pyDLM, that looks promising, but it would be great to hear your thoughts on this
package and this approach.
Jason Brownlee September 6, 2018 at 2:07 pm #
REPLY 
Sounds good, I hope to cover state space methods in the future. To be honest,
I’ve had limited success but also limited exposure with the methods.
Not familiar with the lib. Let me know how you go with it.
Alex Rodriguez April 18, 2019 at 7:30 am #
REPLY 
Indeed it’s an excellent lib.
I use it almost everyday and it really improved the effectiveness of my forecasts over any
other method.
Roberto Tomás September 27, 2018 at 7:38 am #
REPLY 
Hi Jason, I noticed using VARMAX that I had to remove seasonality — enforcing
stationarity .. now I have test and predictions data that I cannot plot (I can, but it doesn’t look
right _at all_). I’m wondering if there are any built-ins that handle translation to and from
seasonality for me? My notebook is online:
https://nbviewer.jupyter.org/github/robbiemu/location-metricdata/blob/master/appData%20and%20locationData.ipynb
Jason Brownlee September 27, 2018 at 2:43 pm #
REPLY 
Typically I would write a function to perform the transform and a sister function to
invert it.
I have examples here:
https://machinelearningmastery.com/machine-learning-data-transforms-for-time-seriesforecasting/
Does that help?
Sara October 2, 2018 at 7:36 am #
REPLY 
Thanks for your great tutorial posts. This one was very helpful. I am wondering if
there is any method that is suitable for multivariate time series with a trend or/and seasonal
components?
Jason Brownlee October 2, 2018 at 11:03 am #
REPLY 
Yes, you can try MLPs, CNNs and LSTMs.
You can experiment with each with and without data prep to make the series stationary.
Sara October 3, 2018 at 1:48 am #
REPLY 
Thanks for your respond. I also have another question I would appreciate if
you help me.
I have a dataset which includes multiple time series variables which are not stationary
and seems that these variables are not dependent on each other. I tried ARIMA for
each variable column, also VAR for the pair of variables, I expected to get better result
with ARIMA model (for non-stationarity of time series) but VAR provides much better
prediction. Do you have any thought why?
Jason Brownlee October 3, 2018 at 6:20 am #
No, go with the method that gives the best performance.
REPLY 
Eric October 17, 2018 at 9:52 am #
REPLY 
Hi Jason,
In the (S/V)ARIMAX procedure, should I check to see if my exogenous regressors are
stationary and difference if them if necessary before fitting?
Y = data2 = [x + random() for x in range(101, 200)]
X = data1 = [x + random() for x in range(1, 100)]
If I don’t, then I can’t tell if a change in X is related to a change in Y, or if they are both just
trending with time. The time trend dominates as 0 <= random() <= 1
In R, Hyndman recommends "[differencing] all variables first as estimation of a model with
non-stationary errors is not consistent and can lead to “spurious regression”".
https://robjhyndman.com/hyndsight/arimax/
Does SARIMAX handle this automatically or flag me if I have non-stationary regressors?
Thanks
Jason Brownlee October 17, 2018 at 2:27 pm #
REPLY 
No, the library will not do this for you. Differencing is only performed on the
provided series, not the exogenous variables.
Perhaps try with and without and use the approach that results in the lowest forecast error
for your specific dataset.
Andrew K October 23, 2018 at 9:09 am #
REPLY 
Hi Jason,
Thank you for this wonderful tutorial.
I do have a question regarding data that isn’t continuous, for example, data that can only be
measured during daylight hours. How would you approach a time series analysis (forecasting)
with data that has this behavior? Fill non-daylight hour data with 0’s or nan’s?
Thanks.
Jason Brownlee October 23, 2018 at 2:25 pm #
REPLY 
I’d encourage you to test many different framings of the problem to see what
works.
If you want to make data contiguous, I have some ideas here:
https://machinelearningmastery.com/handle-missing-timesteps-sequence-predictionproblems-python/
Khalifa Ali October 23, 2018 at 4:48 pm #
REPLY 
Hey..
Kindly Help us in making hybrid forecasting techniques.
Using two forecasting technique and make a hybrid technique from them.
Like you may use any two techniques mentioned above and make a hybrid technique form
them.
Thanks.
Jason Brownlee October 24, 2018 at 6:25 am #
REPLY 
Sure, what problem are you having with using multiple methods exactly?
Mohammad Alzyout October 31, 2018 at 6:25 pm #
REPLY 
Thank you for your excellent and clear tutorial.
I wondered which is the best way to forecast the next second Packet Error Rate in DSRC
network for safety messages exchange between vehicles to decide the best distribution over
Access Categories of EDCA.
I hesitated to choose between LSTM or ARMA methodology.
Could you please guide me to the better method of them ?
Kindly, note that I’m beginner in both methods and want to decide the best one to go deep
with it because I don’t have enouph time to learn both methods especially they are as I think
from different backgrounds.
Thank you in advance.
Best regards,
Mohammad.
Jason Brownlee November 1, 2018 at 6:03 am #
REPLY 
I recommend testing a suite of methods in order to discover what works best for
your specific problem.
Jawad November 8, 2018 at 12:33 am #
REPLY 
Hi Jason,
Thanks for great post. I have 2 questions. First, is there a way to calculate confidence
intervals in HWES, because i could not find any way in the documentation. And second, do
we have something like ‘nnetar’ R’s neural network package for time series forecasting
available in python.
Regards
Jason Brownlee November 8, 2018 at 6:10 am #
REPLY 
I’m not sure if the library has a built in confidence interval, you could calculate it
yourself:
https://machinelearningmastery.com/confidence-intervals-for-machine-learning/
What is “nnetar”?
joao May 4, 2020 at 3:50 am #
REPLY 
https://www.rdocumentation.org/packages/forecast/versions/8.12/topics/nnetar
Jawad Iqbal November 22, 2018 at 8:46 am #
REPLY 
Thanks for your reply Jason. “nnetar” is a function in R,
https://www.rdocumentation.org/packages/forecast/versions/8.4/topics/nnetar
it is used for time series forecasting. I could not find anything similar in Python.
but now i am using your tutorial of LSTM for time series forecasting.
And i am facing an issue that my data points are 750. and when i do prediction the way you
have mentioned i.e. feed the one step forecast back to the new forecast step. So, the plot of
my forecasting is just the repetition of my data. Forecast look just like the cyclic repetition of
the training data. I don’t know what am i missing.
Jason Brownlee November 22, 2018 at 2:08 pm #
REPLY 
Perhaps try this tutorial:
https://machinelearningmastery.com/how-to-develop-lstm-models-for-time-seriesforecasting/
Rima December 4, 2018 at 9:59 pm #
REPLY 
Hi Jason,
Thank you for this great post!
In VARMAX section, at the end you wrote:
“The method is suitable for univariate time series without trend and seasonal components and
exogenous variables.”
I understand from the description of VARMAX that it takes as input, multivariate time series
and exogenous variables. No?
Another question, can we use the seasonal_decompose
(https://www.statsmodels.org/dev/generated/statsmodels.tsa.seasonal.seasonal_decompose.
html) function in python to remove the seasonality and transform our time series to stationary
time series? If so, is the result residual (output of seasonal_decompose) is what are we
looking for?
Thanks!
Rima
Jason Brownlee December 5, 2018 at 6:16 am #
REPLY 
Thanks, fixed.
Rima December 11, 2018 at 9:36 pm #
REPLY 
What about Seasonal_decompose method? Do we use residual result or the
trend?
Jason Brownlee December 12, 2018 at 5:53 am #
REPLY 
Sorry, I don’t understand, perhaps you can elaborate your question?
Rima December 12, 2018 at 7:36 pm #
The seasonal_decompose function implemented in python gives us
4 resutls: the original data, the seasonal component, the trend component
and the residual component. Which component should we use to forecast this
curve? the residual or the trend component?
Jason Brownlee December 13, 2018 at 7:50 am #
I generally don’t recommend using the decomposed elements in
forecasting. I recommend performing the transforms on your data yourself.
Lucky December 5, 2018 at 12:49 am #
REPLY 
Hi Jason,
Could you please help me list down the names of all the models available to forecast
a univariate time series?
Thanks!
Jason Brownlee December 5, 2018 at 6:18 am #
REPLY 
Does the above post not help?
Jane December 6, 2018 at 5:21 am #
REPLY 
Hi Jason,
Thank you this was super helpful!
For the AR code, is there any modification I can make so that model predicts multiple periods
as opposed to the next one? For example, if am using a monthly time series, and have data
up until August 2018, the AR predicts September 2018. Can it predict September 2018,
October, 2018, and November 2018 based on the same model and give me these results?
Jason Brownlee December 6, 2018 at 6:03 am #
REPLY 
Yes, you can specify the interval for which you need a prediction.
Jane December 7, 2018 at 3:29 am #
REPLY 
How might I go about doing that? I have read through the statsmodel
methods and have not found a variable that allows this
Jason Brownlee December 7, 2018 at 5:25 am #
REPLY 
The interval is specified either to the forecast() or the predict() method, I
given an example here that applies to most statsmodels forecasting methods:
https://machinelearningmastery.com/make-sample-forecasts-arima-python/
Abzal June 28, 2020 at 6:04 am #
REPLY 
Hi Jason,
I have dynamic demand forecasting problem, i.e. simple time series but with
DaysBeforeDeparture complexity added.
Historical data looks like:
daysbeforedeparture – DepartureDate Time – Bookings
175. 21 09 2018. 16 00 00 – 10
Etc.
So taking into account the dynamics (daysbeforedeparture) is vital.
I am trying to use fbProphet model, aggregating time series by hour, but no idea how
to deal with DBDeparture feature.
Can you give me some directions?
Jason Brownlee June 29, 2020 at 6:20 am #
REPLY 
I think the date is redundant as you already have days before departure.
I think you may have 2 inputs, the days before departure, bookings, and one
output, the bookings. This would be a multivariate input and univariate output. Or
univariate forecasting with an exog variable.
In fact, if you have sequential data for days before departure, it is also redundant,
and you can model bookings directly as a univariate time series.
This may help:
https://machinelearningmastery.com/taxonomy-of-time-series-forecastingproblems/
Esteban December 21, 2018 at 6:56 am #
REPLY 
Hi, thank you so much for your post.
I have a question, have you used or have you any guidelines for the use of neural networks in
forescating time series, using CNN and LSTMboth together?
Jason Brownlee December 21, 2018 at 3:15 pm #
REPLY 
Yes, I have many examples and a book on the topic. You can get started here:
https://machinelearningmastery.com/start-here/#deep_learning_time_series
mk December 22, 2018 at 10:34 pm #
REPLY 
All methods have common problems. In real life, we do not need to predict the
sample data. The sample data already contains the values of the next moment. The so-called
prediction is only based on a difference, time lag. That is to say, the best prediction is
performance delay. If we want to predict the future, we don’t know the value of the current
moment. How do we predict? Or maybe we have collected the present and past values,
trained for a long time, and actually the next moment has passed. What need do we have to
predict?
Jason Brownlee December 23, 2018 at 6:06 am #
REPLY 
You can frame the problem any way you wish, e.g. carefully define what inputs
you have and what output you want to predict, then fit a model to achieve that.
Dr. Omar January 2, 2019 at 1:40 am #
REPLY 
Dear Jason : your post and book look interesting , I am interested in forecasting a
daily close price for a stock market or any other symbol, data collected is very huge and
contain each price ( let’s say one price for each second) , can you briefly tell how we can
predict this in general and if your book and example codes if applied will yield to future data.
can we after inputting our data and producing the plot for the past data , can we extend the
time series and get the predicted priced for next day/month /year , please explain
Jason Brownlee January 2, 2019 at 6:41 am #
REPLY 
This is a common question that I answer here:
https://machinelearningmastery.com/faq/single-faq/can-you-help-me-with-machinelearning-for-finance-or-the-stock-market
AD January 4, 2019 at 7:51 pm #
REPLY 
Hi Jason,
Thank you for this great post.
I have a requirement of predicting receipt values for open invoices of various customers. I am
taking closed invoices – whose receipt amount is used to create training data and open
invoices as test data.
Below is the list of columns I will be getting as raw data
For Test Data – RECEIPT_AMOUNT, RECEIPT_DATE will be blank, depicting Open Invoices
For Training Data – Closed Invoices will have receipt amount and receipt date
CUSTOMER_NUMBER
CUSTOMER_TRX_ID
INVOICE_NUMBER
INVOICE_DATE
RECEIPT_AMOUNT
BAL_AMOUNT
CUSTOMER_PROFILE
CITY_STATE
STATE
PAYMENT_TERM
DUE_DATE
PAYMENT_METHOD
RECEIPT_DATE
It would be a great help if you can guide me which algo be suitable for this requirement. I think
a multivariate method can satisfy this requirement
Thanks,
AD
Jason Brownlee January 5, 2019 at 6:53 am #
REPLY 
I recommend the following process for new predictive modeling problems:
https://machinelearningmastery.com/start-here/#process
Marius January 8, 2019 at 7:17 am #
REPLY 
Hi Jason,
Are STAR models relevant here as well?
Kindest
Marius
Jason Brownlee January 8, 2019 at 11:12 am #
REPLY 
What are star models?
Kostyantyn Kravchenko June 27, 2019 at 8:53 pm #
REPLY 
Hi Jason, STAR models are Space-Time Autoregression models. I have the
same question. I have a multivariate time-series with additional spatial dimension:
latitude and longitude. So we need to account not only for the time lags but also for
the spacial interactions. I’m trying to find a clear example in Python with no luck so
far…
Jason Brownlee June 28, 2019 at 6:01 am #
What are you’re inputs and outputs exactly?
REPLY 
Heracles January 11, 2019 at 8:35 pm #
REPLY 
Hi Jason,
Thanks for this.
I want to forecast whether an event would happen or not. Would that SARMAR actually work
work if we have a binary column in it?
How would I accomplish something like this including the time?
Jason Brownlee January 12, 2019 at 5:40 am #
REPLY 
Sounds like it might be easier to model the problem as time series classification.
I have some examples of activity recognition, which is time series classification that might
provide a good starting point:
https://machinelearningmastery.com/start-here/#deep_learning_time_series
Gary Morton January 13, 2019 at 5:00 am #
REPLY 
Good morning
A quality cheat sheet for time series, which I took time to re-create and decided to try an
augment by adding code snippets for ARCH and GARH
It did not take long to realize that Statsmodels does not have an ARCH function, leading to a
google search that took me directly to:
https://machinelearningmastery.com/develop-arch-and-garch-models-for-time-seriesforecasting-in-python/
Great work =) Thought to include here as I did not see a direct link, sans your above comment
on thinking to do an ARCH and GARCH module.
also for reference:
LSTM time series model
https://machinelearningmastery.com/how-to-develop-lstm-models-for-multi-step-time-seriesforecasting-of-household-power-consumption/
MLP and Keras Time Series
https://machinelearningmastery.com/time-series-prediction-with-deep-learning-in-python-withkeras/
Cheers and thank you
-GM
REPLY 
Jason Brownlee January 13, 2019 at 5:45 am #
Thanks, and many more here, but neural nets are not really “classic” methods
and arch only forecasts volatility:
https://machinelearningmastery.com/start-here/#deep_learning_time_series
REPLY 
Mahmut COLAK January 14, 2019 at 10:08 am #
Hi Jason,
Thank you very much this paper. I have a time series problem but i can’t find any technique
for applying. My dataset include multiple input and one output like multiple linear regression
but also it has timestamp. Which algorithm is the best solution for my problem?
Thanks.
REPLY 
Jason Brownlee January 14, 2019 at 11:15 am #
I have many exmaples you can get started here:
https://machinelearningmastery.com/start-here/#deep_learning_time_series
REPLY 
Mahmut COLAK January 14, 2019 at 10:16 am #
Hi Jason,
I have a problem about time series data.
My dataset include multiple input and one output.
Normally it is like multiple linear regression but as additional has timestamp
🙁
So i can’t find any solution or algorithm.
For example: AR, MA, ARIMA, ARIMAX, VAR, SARIMAX or etc.
Which one is the best for my problem?
Thanks.
Jason Brownlee January 14, 2019 at 11:15 am #
REPLY 
I recommend testing a suite of methods and discover what works best for your
specific dataset.
RedzCh January 18, 2019 at 11:12 pm #
REPLY 
one thing is there any methods to do grouped forecasting by keys or category so you
have lots of forecasts , there is this on R to an extent
Jason Brownlee January 19, 2019 at 5:41 am #
REPLY 
I’m not sure I follow, can you elaborate please?
Rodrigo January 18, 2019 at 11:15 pm #
REPLY 
First of all, I have read two of your
books(Basics_for_Linear_Algebra_for_Machine_Learning and
deep_learning_time_series_forecasting) and the simplicity with which you explain difficult
concepts is brilliant. I’m using the second one to face the problem hat I present below.
I’m facing a predicting problem for food alerts. The goal is to predict the variables of the most
probable alert in the next x days (also any information I could get about future alerts is really
useful for me).Alerts are recorded over time (so it’s a time series problem).
The problem is that observations are not uniform over time (not separated by equal time
lapses), i.e: since alerts are only recorded when they happen, there can be one day without
alerts and another with 50 alerts. As you indicate in your book, it is a discontiguous time
series.
The entry for the possible model could be the alerts (each alert correctly coded as they are
categorical variables) of the last x days, but this entry must have a fixed size/format. Since the
time windows don’t have the same number of alerts, I don’t know what is the correct way to
deal with this problem.
Any data formatting suggestion to make the observations uniform over time?
Or should I just face the problem in a different way (different inputs)?
Thank you for your great work.
Jason Brownlee January 19, 2019 at 5:44 am #
REPLY 
Sounds like a great problem!
There are many ways to frame and model the problem and I would encourage you to
explore a number and discover what works best.
First, you need to confirm that you have data that can be used to predict the outcome,
e.g. is it temporally dependent, or whatever it is dependent upon, can the model get
access to that.
Then, perhaps explore modeling it as a time series classification problem, e.g. is the even
going to occur in this interval. Explore different interval sizes and different input history
sizes and see what works.
Let me know how you go.
Mery January 28, 2019 at 2:33 am #
REPLY 
Hello Sir,
Thank you for these information
I have a question.
I wanna know if we can use the linear regression model for time series data ?
Jason Brownlee January 28, 2019 at 7:15 am #
REPLY 
You can, but it probably won’t perform as well as specalized linear methods like
SARIMA or ETS.
sunil February 5, 2019 at 5:40 pm #
REPLY 
I have time series data,i want to plot the seasonality graph from it. I am familiar with
holt-winter. Are there any other methods?
Jason Brownlee February 6, 2019 at 7:38 am #
REPLY 
You can plot the series directly to see any seasonality that may be present.
Sai Teja February 11, 2019 at 9:11 pm #
REPLY 
Hi Jason Brownlee
like auto_arima function present in the R ,Do we have any functions like that in python
for VAR,VARMAX,SES,HWES etc
Jason Brownlee February 12, 2019 at 8:00 am #
REPLY 
Yes, I have written a few examples. Perhaps start here:
https://machinelearningmastery.com/how-to-grid-search-sarima-model-hyperparametersfor-time-series-forecasting-in-python/
Michal February 13, 2019 at 1:08 am #
REPLY 
Thank you, this list is great primer!
Jason Brownlee February 13, 2019 at 8:00 am #
REPLY 
I’m glad it was helpful.
Bilal February 15, 2019 at 8:41 am #
REPLY 
Dear Jason,
Thanks for your valuable afford and explanations in such a simple way…
What about the very beginning models of
– Cumulative
– Naive
– Holt’s
– Dampened Holt’s
– Double ESM
I would be very good to see the structural developments of the code from simple to more
complex one.
Thank you very much in advance.
Best regards,
Bilal
Jason Brownlee February 15, 2019 at 2:17 pm #
REPLY 
Thanks for the suggestion.
Ayoub Benaissa March 2, 2019 at 8:44 am #
REPLY 
I was told to build a bayesian regression forecast
which one of these is the best?
because I did not understand “bayesian regression” meaning
Jason Brownlee March 2, 2019 at 9:37 am #
REPLY 
Perhaps ask the person who gave you the assignment what they meant exactly?
Rafael March 12, 2019 at 12:46 am #
REPLY 
Thank you, i have a datset en csv format and i can open it in excel, it has data since
1984 until 2019, I want to train an artificial neural network in python i order to make frecastig
or predictions about that dataset in csv format, I was thinking in a MLP, coul you help me
Jason, a guide pls. Many thanks.
Jason Brownlee March 12, 2019 at 6:54 am #
REPLY 
Sounds great, you can get started here:
https://machinelearningmastery.com/start-here/#deep_learning_time_series
Venkat March 24, 2019 at 5:00 pm #
REPLY 
Dear Jason,
Thank you for your well written quick great info.
Working on one of the banking use cases i.e. Current account and Saving account attrition
prediction.
We are using the last 6 months data for training, we need to predict customers whose balance
will reduce more than 70% with one exception, as long money invested in the same bank it is
fine.
Great, if you could suggest, which models or time series models will be the best options to try
in this case?
Jason Brownlee March 25, 2019 at 6:42 am #
REPLY 
I recommend this process:
https://machinelearningmastery.com/how-to-develop-a-skilful-time-series-forecastingmodel/
Augusto O. Rodero March 29, 2019 at 8:08 pm #
REPLY 
Hi Jason,
Thank you so much for this post I learned a lot. I am a fan of the ARMAX models in my work
as a hydrologist for streamflow forecasting.
I hope you can share something about Gamma autoregressive models or GARMA models
which work well even for non-Gaussian time series which the streamflow time series mostly
are. Can we do GARMA in python?
Jason Brownlee March 30, 2019 at 6:26 am #
REPLY 
Thanks for the suggestion, I’ll look into the method.
Zack March 30, 2019 at 11:18 pm #
REPLY 
This blog is very helpful to a novice like me. I have been running the examples you
have provided with some changes to create seasonality for example (period of 10 as in 0 to 9,
back to 0, again to 9 with randomness thrown in). Linear regression seems to be better at it
than the others which I find surprising. What am I missing?
Jason Brownlee March 31, 2019 at 9:30 am #
REPLY 
You’re probably not missing anything.
If a simpler model works, use it!
Andrew April 1, 2019 at 10:01 pm #
REPLY 
Hi Jason,
Thank you for all your posts, they are so helpful for people who are starting in this area. I am
trying to forecast some data and they recommended me to use NARX, but I haven’t found a
good implementation in python. Do you know other method implemented in python similar to
NARX?
Jason Brownlee April 2, 2019 at 8:11 am #
REPLY 
You can use a SARIMAX as a NARX, just turn off all the aspects you don’t need.
Berta April 19, 2019 at 10:19 pm #
REPLY 
Hi Jason,
Thank you for all you share us. it’s very helpful.
Jason Brownlee April 20, 2019 at 7:38 am #
REPLY 
I’m happy to hear that.
jessy April 20, 2019 at 11:30 am #
REPLY 
sir,
above 11 models are time series forecasting models, in few section you are discussing about
persistence models…what is the difference.
Jason Brownlee April 21, 2019 at 8:18 am #
REPLY 
Persistence is a naive model, e.g. “no model”.
Naomi May 4, 2019 at 1:55 am #
Very good work. Thanks for sharing.
REPLY 
The line in VARMAX “The method is suitable for multivariate time series without trend and
seasonal components and exogenous variables.” is very confusing.
I guess you mean no trend no seaonal but with exogenous?
Jason Brownlee May 4, 2019 at 7:12 am #
REPLY 
Yes, fixed. Thanks!
User104 May 17, 2019 at 2:20 pm #
REPLY 
Hi Jason,
Thanks for the post. It was great and easy to understand for a beginner in time series.
I have data of past 4 years of number of users logged in for a day .
I want to predict the number of users for a day per month.
I used ARIMA but I am getting RMSE 2749 and R2 score 60% .
Can you please suggest methods to increase the accuracy as well as RMSE.
Thanks
Jason Brownlee May 17, 2019 at 2:53 pm #
REPLY 
Perhaps try some alternate configurations for the ARIMA?
Perhaps try using SARIMA to capture any seasonality?
Perhaps try ETS?
Menghok June 4, 2019 at 9:40 pm #
REPLY 
Hello Jason, thanks for your explanation.
I have a question. What if my data is time series with multiple variables including categorical
data, which model should be used for this? For example, i’m predicting The Air pollution level
using the previous observation value of Temperature + Outlook (rain or not).
Thank you.
Jason Brownlee June 5, 2019 at 8:41 am #
REPLY 
It is a good idea to encode categorical data, e.g. with an integer, one hot
encoding or embedding.
Ramesh July 31, 2019 at 2:34 pm #
REPLY 
Hi Menghok, did you get any luck in implementing forecasting problem when you
have one more categorical variable in dataset
Prasanna June 17, 2019 at 3:45 pm #
REPLY 
Hi Jason,
Thanks for the great post again, wonderful learning experience.
Do you have R codes for the time series methods you described in your article?
or Can you suggest me a good source where can i get R codes to learn some of these
methods?
Thanks
Jason Brownlee June 18, 2019 at 6:32 am #
REPLY 
Sorry, I don’t have R code for time series, perhaps you can start here:
https://machinelearningmastery.com/books-on-time-series-forecasting-with-r/
Ibrahim Rashid June 18, 2019 at 8:39 pm #
REPLY 
Thanks for the post. Please do check out AnticiPy which is an open-source tool for
forecasting using Python and developed by Sky.
The goal of AnticiPy is to provide reliable forecasts for a variety of time series data, while
requiring minimal user effort.
AnticiPy can handle trend as well as multiple seasonality components, such as weekly or
yearly seasonality. There is built-in support for holiday calendars, and a framework for users
to define their own event calendars. The tool is tolerant to data with gaps and null values, and
there is an option to detect outliers and exclude them from the analysis.
Ease of use has been one of our design priorities. A user with no statistical background can
generate a working forecast with a single line of code, using the default settings. The tool
automatically selects the best fit from a list of candidate models, and detects seasonality
components from the data. Advanced users can tune this list of models or even add custom
model components, for scenarios that require it. There are also tools to automatically
generate interactive plots of the forecasts (again, with a single line of code), which can be run
on a Jupyter notebook, or exported as .html or .png files.
Check it out here:
https://pypi.org/project/anticipy/
Jason Brownlee June 19, 2019 at 7:52 am #
REPLY 
Thanks for the note.
Min June 19, 2019 at 7:46 am #
REPLY 
Hi Jason,
Thanks for this great post!
I have a question for time series forecasting. Have you heard about Dynamic Time Warping?
As far as I know, this is a method for time series classification/clustering, but I think it can also
be used for forecasting based on the similar time series. What do you think about this method
compared to ARIMA? Do you think it will be better if I combine both two methods? For
example, use DTW to group similar time series and then use ARIMA for each group?
Thanks
Jason Brownlee June 19, 2019 at 8:20 am #
REPLY 
I don’t have any posts on the topic, but I hope to cover it in the future.
lda4526 June 22, 2019 at 7:11 am #
REPLY 
Can you please explain why you use len(data) in your predict arguments? I was
using the .forecast feature for a while which is for out of sample forecasts but I keep getting an
error on my triple expo smoothing. Apparently, the .predict can be used for in-sample
prediction as well as out of sample. The arguments are start and end, and you use len(data)
for both which is confusing me. Will this really forecast or will it just produce a forecast for
months in the past?
Jason Brownlee June 22, 2019 at 7:43 am #
REPLY 
Great question.
To predict the next or index beyond the known data.
More details here:
https://machinelearningmastery.com/make-sample-forecasts-arima-python/
lda4526 June 25, 2019 at 1:03 am #
REPLY 
Thanks for the reply! I was reading through the explanation in your linked
article and it was great. Can the .predict() do multiple periods in the future like
.forecast? I was using .forecast(12) for forecasting 12 months into the future.
lda4526 June 25, 2019 at 1:17 am #
REPLY 
EDIT: Dumb question- did not read until the end. If you got time, check
out my stack post though:
https://stackoverflow.com/questions/56709745/statsmodels-operands-could-not-
be-broadcast-together-in-pandas-series . I think i found some error in statsmodels
as the error is thrown in the .forecast function as it wants me to specify a
frequency. I found the potential misstep by reading through the actual code for
ExponentialSmoothing and it was the only part that really referenced the
frequency. Its either that, or my noob is really showing.
Jason Brownlee June 25, 2019 at 6:27 am #
Perhaps this code example will help:
https://machinelearningmastery.com/how-to-grid-search-triple-exponentialsmoothing-for-time-series-forecasting-in-python/
karim June 23, 2019 at 9:05 pm #
REPLY 
Hi Jason,
Thanks for all of your awesome tutorial.
Can you please provide any link of your tutorial which has described forecasting of
multivariate time series with a statistical model like VAR?
Jason Brownlee June 24, 2019 at 6:27 am #
REPLY 
I do not have a tutorial on VAR, sorry.
karim June 25, 2019 at 7:00 am #
REPLY 
OK, thanks for your reply. Hopefully, if you can manage time will come with a tutorial
on VAR for us.
🙂
qwizak July 2, 2019 at 10:56 pm #
REPLY 
Hi Jason, do you cover all these models using a real dataset in your book?
Jason Brownlee July 3, 2019 at 8:33 am #
REPLY 
I focus on AR/ARIMA in the intro book and SARIMA/ETS+deep learning in
the deep learning time series book.
Shabnam July 3, 2019 at 11:26 pm #
REPLY 
Hi Jason,
Thanks for the helpful tutorial. I’ve been trying to solve a sales forecast problem but haven’t
been any successful. The data is the monthly records of product purchases (counts) with their
respective prices for ten years. The records do not show either a significant auto-correlation
for a wide range of lags or seasonality. The records are stationary though.
Among the time series models, I have tried (S)ARIMA, exponential methods, the Prophet
model, and a simple LSTM. I have also tried regression models using a number of industrial
and financial indices and the product price. Unfortunately, no method has led to an acceptable
result. With regression models, the test R^2 is always negative.
My questions are:
* What category of problems is this problem more relevant to?
* Do you have any suggestions for possibly suitable approaches to follow for this kind of
problems?
Thank you in advance.
Shabnam
Jason Brownlee July 4, 2019 at 7:49 am #
REPLY 
Perhaps the time series is not predictable?
Shabnam July 8, 2019 at 11:04 pm #
REPLY 
I guess that might be the case. I’m also guessing that maybe I don’t have
sufficiently relevant explanatory variables to obtain a good regression model.
Thanks for your feedback though. And, thanks again for your very helpful
tutorials.
Shabnam
Jason Brownlee July 9, 2019 at 8:11 am #
REPLY 
You’re welcome.
George July 9, 2019 at 1:05 am #
REPLY 
Hello Jason,
Do you know if there any way to randomly sample a fitted VARMA time series using the
statsmodel library. Just like using the sm.tsa.arma_generate_sample for the ARMA.
I cant seem to see this how this is done anywhere.
Jason Brownlee July 9, 2019 at 8:12 am #
REPLY 
Not off hand, sorry.
Manjinder Singh July 11, 2019 at 9:06 pm #
REPLY 
Hello Jason,
It is really nice and informative article.
I am having network data and in that data there are different parameters (network incidents)
which slows down the network. From the lot of parameters one is network traffic. I have DATE
and TIME when network traffic crosses a certain threshold at certain location. I need to draw a
predictive model so that i can spot when network traffic is crossing threshold value at a
particular location, so that i can take preventive measures prior to occurrence of that
parameter at that place.
So please can you suggest me appropriate model for this problem.
Jason Brownlee July 12, 2019 at 8:41 am #
REPLY 
Perhaps it might be interesting to explore modeling the problem as a time series
classification?
Juan Flores July 11, 2019 at 9:56 pm #
REPLY 
Hi, Jason,
We’ve been having trouble with statsmodels’ ARIMA. It just doesn’t work and takes forever.
What can you tell us about these issues? Do you know of any alternatives to statsmodels?
ThX,
Juan
Jason Brownlee July 12, 2019 at 8:43 am #
REPLY 
Perhaps try a sklearn linear regression model directly?
Juan J. Flores July 13, 2019 at 10:47 pm #
REPLY 
Dear Jason,
Thanks for the answer.
Of course there are many regression models available in sklearn. The point is that
statsmodels seems to fail miserably, both in time and accuracy. That is, with respect
to their arima (family) set of functions.
Question is if you know an alternative python library providing that missing
functionality. R works well. Mathematica even better. At the moment, my students are
working on interfacing with R, since we have not found a sound Python library for
arima.
Have a good one.
Juan
Jason Brownlee July 14, 2019 at 8:11 am #
REPLY 
I see, good question.
I have found the statsmodels implementation to be reliable, but only if the data is
sensible and only if the order is modest.
I cannot recommend another library at this time. R may be slightly more reliable,
but is not bulletproof.
Juan Jose Flores October 10, 2019 at 9:53 pm #
Thanks, Jason.
We ended up running everything on Mathematica. It works way better. A more
robust python library for ARIMA models is needed.
Best,
Juan
Jason Brownlee October 11, 2019 at 6:18 am #
Nice work!
I agree.
Manjinder Singh July 12, 2019 at 7:12 pm #
REPLY 
In time series classification when I am plotting it is showing day wise data . For an
instance if i am taking data of past 1 month and applying Autoregression time series
classification on it then i am not able to fetch detailed outputs from that chart. From detailed
output I mean that 1 incident is occuring number of times in a day so I want visibility in such a
way so that everytime an incident occur it should be noticed on that plot.
Is there any precise way by which I can do it.I would be really thankful if you would help me.
Thank you
Jason Brownlee July 13, 2019 at 6:54 am #
REPLY 
Perhaps resample the data to daily before or after modeling, depending on
whether you want model data this way or only view forecasts this way.
Berns B. August 8, 2019 at 9:40 am #
REPLY 
I can’t seem to make VAR work? Gives me a lot of errors?
—————————————————————————
ValueError Traceback (most recent call last)
in ()
11 # fit model
12 model = VAR(data)
—> 13 model_fit = model.fit()
14 # make prediction
15 yhat = model_fit.forecast(model_fit.y, steps=1)
D:\Users\Berns\Anaconda3\envs\time_series_p27\lib\sitepackages\statsmodels\tsa\vector_ar\var_model.pyc in fit(self, maxlags, method, ic, trend,
verbose)
644 self.data.xnames[k_trend:])
645
–> 646 return self._estimate_var(lags, trend=trend)
647
648 def _estimate_var(self, lags, offset=0, trend=’c’):
D:\Users\Berns\Anaconda3\envs\time_series_p27\lib\sitepackages\statsmodels\tsa\vector_ar\var_model.pyc in _estimate_var(self, lags, offset, trend)
666 exog = None if self.exog is None else self.exog[offset:]
667 z = util.get_var_endog(endog, lags, trend=trend,
–> 668 has_constant=’raise’)
669 if exog is not None:
670 # TODO: currently only deterministic terms supported (exoglags==0)
D:\Users\Berns\Anaconda3\envs\time_series_p27\lib\sitepackages\statsmodels\tsa\vector_ar\util.pyc in get_var_endog(y, lags, trend, has_constant)
36 if trend != ‘nc’:
37 Z = tsa.add_trend(Z, prepend=True, trend=trend,
—> 38 has_constant=has_constant)
39
40 return Z
D:\Users\Berns\Anaconda3\envs\time_series_p27\lib\sitepackages\statsmodels\tsa\tsatools.pyc in add_trend(x, trend, prepend, has_constant)
97 col_const = x.apply(safe_is_const, 0)
98 else:
—> 99 ptp0 = np.ptp(np.asanyarray(x), axis=0)
100 col_is_const = ptp0 == 0
101 nz_const = col_is_const & (x[0] != 0)
D:\Users\Berns\Anaconda3\envs\time_series_p27\lib\sitepackages\numpy\core\fromnumeric.pyc in ptp(a, axis, out, keepdims)
2388 else:
2389 return ptp(axis=axis, out=out, **kwargs)
-> 2390 return _methods._ptp(a, axis=axis, out=out, **kwargs)
2391
2392
D:\Users\Berns\Anaconda3\envs\time_series_p27\lib\sitepackages\numpy\core\_methods.pyc in _ptp(a, axis, out, keepdims)
151 def _ptp(a, axis=None, out=None, keepdims=False):
152 return um.subtract(
–> 153 umr_maximum(a, axis, None, out, keepdims),
154 umr_minimum(a, axis, None, None, keepdims),
155 out
ValueError: zero-size array to reduction operation maximum which has no identity
Jason Brownlee August 8, 2019 at 2:21 pm #
Sorry, I’m not sure about the cause of your error.
Perhaps confirm statsmodels is up to date?
REPLY 
Berns B. August 8, 2019 at 12:25 pm #
REPLY 
By the way Doc Jason, I just bought your book today this morning. I have a huge use
case for a time series at work I can use them for.
Jason Brownlee August 8, 2019 at 2:21 pm #
REPLY 
Thanks, you have a lot of fun ahead!
I’m here to help if you have questions, email me directly:
https://machinelearningmastery.com/contact/
Berns B. August 8, 2019 at 1:19 pm #
REPLY 
Darn indentions! Now code works.
# VAR example
from statsmodels.tsa.vector_ar.var_model import VAR
from random import random
# contrived dataset with dependency
data = list()
for i in range(100):
v1 = i + random()
v2 = v1 + random()
row = [v1, v2]
data.append(row)
# fit model
model = VAR(data)
model_fit = model.fit()
# make prediction
yhat = model_fit.forecast(model_fit.y, steps=1)
print(yhat)
Jason Brownlee August 8, 2019 at 2:22 pm #
REPLY 
I’m very happy to hear that.
More on how copy code from posts here:
https://machinelearningmastery.com/faq/single-faq/how-do-i-copy-code-from-a-tutorial
soumyajit August 20, 2019 at 6:27 pm #
REPLY 
Jason , need one clarification , for a SARIMAX model or in general in timeseries
model, should I use .forecast or .predict ? I have got some differences in result using this two .
Please suggest should we use .forecast for train and test ( to get the model fitted values) or
should we use .predict for train and test ( to get the model fitted values) . Also for future
forecast what need to be used ? Please suggest.
Jason Brownlee August 21, 2019 at 6:38 am #
REPLY 
Either, they both do the same thing.
Kristen September 24, 2019 at 1:27 am #
REPLY 
Hi Jason,
GREAT article. I’ve been looking for an overview like this. I do have a side question about a
project I’m working on. I’ve got a small grocery distribution company that wants weekly
forecasts of its 4000+ different products/SKU numbers. I’m struggling with how to produce a
model that can forecast all these different types of time-series trends and seasonalities.
ARIMA with Python doesn’t seem like a good option because of the need to fine tune the
parameters. I would love you’re feedback on the following ideas:
1. Use facebooks prophet for a “good enough” model for all different types of time series
trends and seasonalities.
2. Separate the grocery items into 11-20 broader category groups and then produce individual
models for all those different categories that can then be applied to each individual sku within
that category.
LIMITATIONS:
1. I need this process to be computationally efficient, and a for-loop for 4000 items seems like
a horrible way to go about this.
QUESTIONS:
1. Do i have to model sales and NOT item quantities and why is that?
2. Is there a way to cluster the items with unsupervised learning just based off their trend and
seasonality? Each item does not have good descriptor category so I don’t have much to work
with for unsupervised clustering techniques.
Would love to hear any thoughts you have about this type of problem!
Thanks for ALL the helpful content.
Kristen
Jason Brownlee September 24, 2019 at 7:49 am #
REPLY 
This will give you some ideas of working with multiple SKUs:
https://machinelearningmastery.com/faq/single-faq/how-to-develop-forecast-models-formultiple-sites
Explore groupings by simple aspects like product category, average sales, average gross
in an interval, etc.
Anne Bierhoff October 2, 2019 at 7:45 pm #
REPLY 
Hi Jason,
many thanks for the many informative articles.
I have a simulation model of a system which receives a forecast of a time series as input.
In my scientific work I would like to examine how the performance of the simulation model
behaves in relation to the accuracy of the forecast. So I would like to have forecasts between
80% (bad prediction) and 95% (very good prediction) for my time series.
How would you recommend me to generate such pseudo predictions that are meaningful for
real predictions? Maybe adjusting a mediocre prediction in both direction?
Thanks and best regards
Anne
Jason Brownlee October 3, 2019 at 6:44 am #
REPLY 
Not sure I follow, sorry.
What specific problem are you having exactly?
Anne Bierhoff October 4, 2019 at 12:25 am #
REPLY 
Excuse me, it was also written a bit misleading.
My problem is that my simulation model receives forecasted time series as input, from
which I know from publication papers that they are 95% predictable with a lot of effort
and large amounts of training data.
Simple predictions like the ones I make, however, only reach about 80%.
Nevertheless, I would like to analyze for my scientific work how much the quality of
the simulation model depends on the quality of the forecasts. For example, to say
whether the effort for good forecasts is worth it.
Is there a way to make pseudo forecasts of time series for this purpose? As a basis
the actual data and the forecast data are available with 80% accuracy.
Thanks and best regards
Anne
Jason Brownlee October 4, 2019 at 5:44 am #
REPLY 
Yes, why not contrive forecasts as input and contrive expected outputs
and control the entire system – e.g. a controlled experiment.
I believe that is required for what you’re describing.
If you’re new to computational experimental design, perhaps this book will help:
https://amzn.to/2AFTd7t
Anne Bierhoff October 4, 2019 at 8:14 am #
Thank you very much. I’ll follow up on that tip.
Part of my question also aimed at how I best proceed when contriving
forecasts, as they should be as representative as possible.
The simplest would be to add normal distributed noise to the actual data, but I
don’t know if that would be representative if the error was only caused by
white-noise.
What is your opinion on this issue?
Jason Brownlee October 4, 2019 at 8:37 am #
A linear model (e.g. linear dependency) for generating forecasts
would be the way I would approach it.
Or a controllable simplification of the data you will be working with for real,
e.g. trends/seasonality/level changes/etc.
Sadani October 4, 2019 at 8:38 pm #
REPLY 
Hey Jason, I have a requirement
I have to perform a regression on a data set that has the following data
Age of Person at time of data collection
Date
cholesterol Level
HDL
Event which can be death etc.
Need to find out if there are any patterns in the Cholesterol Level or the HDL Levels prior to
the death event.
I’m trying to do this using Jupyter Notebook. Really appreciate your help sincerely.
Do you have any examples that would be close ?
Jason Brownlee October 6, 2019 at 8:08 am #
REPLY 
Sounds like a great problem, perhaps start with some of the simpler tutorials
here:
https://machinelearningmastery.com/start-here/#timeseries
Jose October 15, 2019 at 3:45 am #
REPLY 
Hey Jason! I am working on supply elasticities for crops in California, I am new using
python your post has been incredible useful, I have one question for my model I need to
develop a time series dynamic model particularly an Autoregressive Distributed Lag (ARDL)
Model, do you have any material related to how perform this type of models on python?
Thanks!
Jason Brownlee October 15, 2019 at 6:19 am #
REPLY 
Sorry, I have not seen this model in Python.
If you can’t locate, perhaps you can implement it yourself? Or call a function from an
implementation in another language?
Why do you need that specific model?
Burcu October 22, 2019 at 11:51 pm #
REPLY 
Hi Jason,
Actually I am very impatient and did not read all the comments but thot that you already knew
them
🙂
I need to make a hierarcial and grouped time series in Python.
I need to predict daily & hourly passenger unit by continent or vessel name. I investigated but
did not find a solution, could you pls direct me what can I do.
Below are my inputs for the model.
Date & Time Vessel Name Continent Passenger Unit
Thank you,
Jason Brownlee October 23, 2019 at 6:49 am #
REPLY 
Perhaps start by fitting one model per “vessel”?
Then later perhaps try fitting models across vessels?
For simple linear models you can start here:
https://machinelearningmastery.com/start-here/#timeseries
For advanced models you can start here:
https://machinelearningmastery.com/start-here/#deep_learning_time_series
Praveen November 13, 2019 at 12:53 am #
REPLY 
Hi Jason,
While forecasting in VAR or VARMAX I’ m not getting the future timestamp associated with it?
Won’t model provide us the future timestamp?
Jason Brownlee November 13, 2019 at 5:47 am #
REPLY 
You will know it relative to the end of your training data.
Prem November 13, 2019 at 3:53 pm #
REPLY 
Hi Jason,
For the simple AR model yhat values is it possible to get the threshold?
data = [x + random() for x in range(1, 100)]
model = AR(data)
model_fit = model.fit()
yhat = model_fit.predict(len(data), len(data))
Thanks
Jason Brownlee November 14, 2019 at 7:57 am #
What threshold?
REPLY 
Prem November 14, 2019 at 3:56 pm #
REPLY 
The forecast, lowerbound and upperbound?
Jason Brownlee November 15, 2019 at 7:43 am #
REPLY 
I think you might be referring to the prediction interval.
This gives an example:
https://machinelearningmastery.com/time-series-forecast-uncertainty-usingconfidence-intervals-python/
Markus December 2, 2019 at 12:08 am #
REPLY 
Hi
Looking at the AR.predict documentation here:
http://www.statsmodels.org/dev/generated/generated/statsmodels.tsa.ar_model.AR.predict.ht
ml#statsmodels.tsa.ar_model.AR.predict
With the given parameters as params, start, end and dynamic, I can’t correspond them to the
method call you have as:
yhat = model_fit.predict(len(data), len(data))
For which exact documented parameters do you pass over len(data) twice?
Thanks.
Jason Brownlee December 2, 2019 at 6:04 am #
REPLY 
That makes a single step prediction for the next time step at the end of the data.
Alternately, you can use model.forecast() in some cases/models.
Nikhil Gupta December 4, 2019 at 6:46 pm #
REPLY 
Thanks Jason. This post is really awesome.
I see that you are using random function to generate the data sets. Can you suggest any
pointers where I can get real data sets to try out these algorithms. If possible IoT data sets
would be preferable.
Jason Brownlee December 5, 2019 at 6:40 am #
REPLY 
Yes, right here:
https://machinelearningmastery.com/faq/single-faq/where-can-i-get-a-dataset-on-___
Juni December 12, 2019 at 12:47 pm #
REPLY 
Hey
It is really great to see all this stuff.
Can you please explain me:
which algorithm should i use when i want to predict the voltage of a battery:ie…
battery voltage is recorded from 4.2 to 3.7 is 6 months which algorithm will be the best one to
predict the next 6 months
Jason Brownlee December 12, 2019 at 1:45 pm #
REPLY 
Good question, this will help:
https://machinelearningmastery.com/how-to-develop-a-skilful-time-series-forecastingmodel/
jhon December 18, 2019 at 3:55 pm #
REPLY 
Buenas tardes, se podría utilizar el walk fordward validación para series de tiempo
multivariado ? es decir una variable Target y varias variables input, y k te haga la técnica de
wall fordward validación?? esa es mi pregunta, saben de algún link o tutoría
Jason Brownlee December 19, 2019 at 6:21 am #
REPLY 
Yes, the same walk-forward validation approach applies and you can evaluate
each variate separately or all together if they have the same units.
A. January 13, 2020 at 12:57 am #
REPLY 
Hi,
Have you ever evaluated the performance of Gaussian processes for time series forecast? Do
you have any material on this (or plan to make a post about this)?
It’s probably not a “classical” method though.
Thanks!
Jason Brownlee January 13, 2020 at 8:21 am #
REPLY 
I do not. I hope to cover it in the future.
Pallavi February 17, 2020 at 4:19 pm #
REPLY 
Hi Jason,
I’m currently working on a sales data set which has got date, location, item and the unit sales.
Time period is 4 yrs data, need to forecast sales for subsequent year -1 month(1-jan to 15
jan). Kindly suggest a model for this multivariate data. Another challenge which i’m currently
facing is working with google collab with restricted RAM size of 25 GB and the data set size is
1M rows.
Please suggest a good model which will handle the memory size as well.
Note: I have change the datatype to reduce the memory, still facing the issue
Jason Brownlee February 18, 2020 at 6:17 am #
REPLY 
I recommend this process:
https://machinelearningmastery.com/how-to-develop-a-skilful-time-series-forecastingmodel/
Amit Patidar March 5, 2020 at 8:27 pm #
REPLY 
Can you briefly explain about Fbprophet, it’s pros and cons etc.
Jason Brownlee March 6, 2020 at 5:31 am #
REPLY 
Thanks for the suggestion.
I have a tutorial on the topic written, it will appear soon.
Ricardo Reis March 21, 2020 at 2:07 am #
REPLY 
Hi Jason,
All these methods seem to focus on two data features:
– evenly spaced time series;
– continuous data.
As it is easy to guess, I have a time series which is both irregular and categorical.
Mine is sensor data. These sensors only detect the presence of a person in a room. Each
entry gives me the start time, duration and room. This is for monitoring one person with health
issues as they move through their flat.
None of the above methods — fantastically depicted, by the way! — is a glove to this hand. I
need to detect patterns, trigger alerts on anomalies and predict future anomalies.
Any suggestions?
Jason Brownlee March 21, 2020 at 8:27 am #
REPLY 
Yes, see this:
https://machinelearningmastery.com/faq/single-faq/how-do-i-handlediscontiguous-time-series-data
William March 22, 2020 at 1:38 am #
REPLY 
I have error executing VARMAX
“ValueError: endog and exog matrices are different sizes”
Jason Brownlee March 22, 2020 at 6:56 am #
REPLY 
Perhaps confirm that the inputs to your model have the same length.
Artur March 22, 2020 at 1:42 am #
REPLY 
Hello,
Are you sure the code is well-formatted ?
”
for i in range(100):
v1 = random()
“
Jason Brownlee March 22, 2020 at 6:57 am #
REPLY 
Fixed, thanks!
LANET March 23, 2020 at 4:39 am #
REPLY 
Hi Dr.Jason,
I have a question about time-series forecasting.I have to predict the value of Time-series A in
the next few hours.And at the same time,the Time-series B have an influence on A.I have two
ideas :
1.X_train is time T and Y_train is the value of A_T and B._T
2 X_train is the value of (A_n, A_n-1, A_n-2,…A_n-k, B_n, B_n-1, B_n-2,…,B_n-k) ,Y_train is
(A_n+1, A_n+2,…,A_n+m)
Which is better?
Jason Brownlee March 23, 2020 at 6:15 am #
REPLY 
Test and compare results.
It might be easier to model it as a multivariate input time series forecasting problem.
The tutorials here will help:
https://machinelearningmastery.com/start-here/#deep_learning_time_series
LANET March 23, 2020 at 8:08 pm #
REPLY 
Thanks! It definitely helps me a lot !
Jason Brownlee March 24, 2020 at 6:00 am #
REPLY 
I’m happy to hear that.
LANET March 23, 2020 at 4:44 am #
REPLY 
Hope for your suggestions.
Thanks and best regards.
Lanet
Jason Brownlee March 23, 2020 at 6:15 am #
REPLY 
You’re welcome.
DEAN MCBRIDE April 7, 2020 at 12:54 am #
REPLY 
Hi Jason
I get numerous warnings for some of the models (e.g. robustness warnings, and model
convergence warnings, etc.) Do you get the same?
Thanks,
Dean
Jason Brownlee April 7, 2020 at 5:52 am #
REPLY 
Sometimes. You can ignore them for now, or explore model configs/data preps
that are more kind to the underlying solver.
DEAN MCBRIDE April 7, 2020 at 4:24 pm #
REPLY 
Thanks Jason.
One other thing – do you know where I could find an explanation on how the solvers
work (relating to the theory) ? Since I’ll need to know what config/parameter changes
will do.
I did access the links you posted (e.g. statsmodels.tsa.ar_model.AR API) , but I don’t
find these very descriptive, and they are without code examples.
Jason Brownlee April 8, 2020 at 7:45 am #
REPLY 
Yes, a textbook on convex optimization, wikipedia, the original papers,
and maybe the scipy API.
Stéfano April 7, 2020 at 1:00 pm #
REPLY 
Hi Jason Brownlee,
I appreciate that you posted this explanation about the models.
I would like to apply the algorithms to my problem.
I was in doubt as to how to extract the predicted value and the current value of each
prediction. I would like to calculate the RMSE, MAPE, among others.
Jason Brownlee April 7, 2020 at 1:33 pm #
REPLY 
You’re welcome.
You can make a prediction by fitting the model on all available data and then calling
model.predict()
rina April 9, 2020 at 8:09 pm #
REPLY 
hello Jason, thank you for your post. it is so interesting.
In fact i have a question. I have many time series Trafic per region. I don’t want ot have 40
models to forecast trafic for each region.
Do you have an idea how can i use one model to predict trafic for all regions so one model to
a multiple time series?
Thank you in advance
Jason Brownlee April 10, 2020 at 8:27 am #
REPLY 
Yes, I list some ideas here:
https://machinelearningmastery.com/faq/single-faq/how-to-develop-forecast-models-formultiple-sites
rina April 10, 2020 at 7:38 pm #
REPLY 
thank you for your answer. for my project i want to have one model to predict
all the values for all cities.
I don’t know wich types of algorithms can i use that accept multiseries can you help
me with this thank you
Jason Brownlee April 11, 2020 at 6:16 am #
REPLY 
Follow this framework to discover the algorithm that works best for your
specific data:
https://machinelearningmastery.com/how-to-develop-a-skilful-time-seriesforecasting-model/
rina April 12, 2020 at 9:04 pm #
thank you for your response. In fact do you have an examples of link
or article with python that forecast with multiple independant time series
my data is in this format:
date ville X(predicted value)
01/01/2016 A 2
01/02/2016 A 4
01/02/2016 A 5
01/01/2016 B 10
01/02/2016 B 11
01/02/2016 B 13
Jason Brownlee April 13, 2020 at 6:14 am #
Yes many – search the blog, perhaps start with the simple examples
in this tutorial:
https://machinelearningmastery.com/how-to-develop-lstm-models-for-timeseries-forecasting/
Nirav April 9, 2020 at 10:33 pm #
REPLY 
I want to fit a curve on time series data. Will this methods work for it or it can be
useful for prediction only?
Jason Brownlee April 10, 2020 at 8:30 am #
REPLY 
Perhaps use the methods here:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html
Alaa May 9, 2020 at 11:01 am #
REPLY 
Dear Jason,
Do you have a blog where you forecast univariate time series using a combination of
exponential smoothing and neural network?
I mean where we give lags of time series to exponential smoothing model and the output of
exponential smoothing will be the input of a neural network?
Thank you
Jason Brownlee May 9, 2020 at 1:51 pm #
REPLY 
I don not, sorry.
QuangAnh May 28, 2020 at 8:21 am #
Hi Jason,
REPLY 
Could you also please review the BATS and TBATS models? (De Livera, A.M., Hyndman,
R.J., & Snyder, R. D. (2011), Forecasting time series with complex seasonal patterns using
exponential smoothing, Journal of the American Statistical Association, 106(496), 1513-1527.)
Like SARIMA, they are quite good to deal with seasonal time series. And I am wondering if
you have any plan to review Granger causality which is often used to find time series
dependencies from multivariate time series? Thank you.
Jason Brownlee May 28, 2020 at 1:23 pm #
REPLY 
Thanks for the suggestion!
adarsh singh June 11, 2020 at 1:44 am #
REPLY 
hello
i have a dtaset of many vehicle which ask me to predict output by taking 5 timeseries input
and i have to do this for all vehicle almost 100 vehicle to improve accuracy of model,can u
help me
Jason Brownlee June 11, 2020 at 6:00 am #
REPLY 
This may give you some ideas:
https://machinelearningmastery.com/faq/single-faq/how-to-develop-forecast-models-formultiple-sites
Shekhar P June 11, 2020 at 4:03 pm #
REPLY 
Hello Sir,
The SARIMAX model you explained here is for single step. Can you let me know, how to do it
for multi step ( with steps = 96 in future) forecasting.
Jason Brownlee June 12, 2020 at 6:08 am #
REPLY 
Specify the number of steps required in the call to the forecast() function.
Puspendra June 18, 2020 at 12:48 am #
REPLY 
Hi Jeson,
Great info. Can you suggest the algorithms which cover multivariate with trend and
seasonality?
Jason Brownlee June 18, 2020 at 6:28 am #
REPLY 
Neural nets:
https://machinelearningmastery.com/start-here/#deep_learning_time_series
Greg June 18, 2020 at 1:20 am #
REPLY 
hey, Jason. there are some changes on the statsmodels library. e.g. on the arima is
now
>> statsmodels.tsa.arima.model
Jason Brownlee June 18, 2020 at 6:28 am #
REPLY 
Thanks.
User1 June 23, 2020 at 7:13 am #
Hi Jason. Thank you for the great post.
REPLY 
It is not very clear to me what is the difference between a multivariate and an exogenous time
series
Can you please clarify that?
Thank you
Jason Brownlee June 23, 2020 at 1:26 pm #
REPLY 
Thanks.
My understanding:
Multivariate refers to multiple parallel input time series that are modeled as sych (lags
obs)
Exogenous variables are simply static regressors that are added to the model (e.g. linear
regression).
t June 25, 2020 at 1:14 am #
REPLY 
statsmodels.tsa.arima_model.ARMA:
Deprecated since version 0.12: Use statsmodels.tsa.arima.model.ARIMA instead…
Jason Brownlee June 25, 2020 at 6:24 am #
REPLY 
Thanks. I will schedule time to update it.
Sha June 29, 2020 at 3:46 pm #
REPLY 
Jason, thanks for all your posts!
I am a bit confused on When to use VAR and when to use ARIMAX? Any explanation would
be much appreciated….
Jason Brownlee June 30, 2020 at 6:13 am #
REPLY 
VAR for when you have multivariate input.
ARX (ARIMAX), the “X”, for when you have a univariate time series with exogenous
variables:
https://en.wikipedia.org/wiki/Exogenous_and_endogenous_variables
If you’re unsure, try both and one will be a natural fit for your data and another won’t. It
might be that clear.
durvesh July 3, 2020 at 6:15 pm #
REPLY 
Hi Sir, Thanks for the amazing tutorial
1. For the SARIMAX seasonal component “m” should it be different than 1 ,get an error when
1 is used .
2. In the predict function why we pass the length as 99 if we want next prediction
Jason Brownlee July 4, 2020 at 5:53 am #
REPLY 
It might depend on your data.
You specify the index or date you want to forecast in the predict() function.
Gaurav August 1, 2020 at 1:21 am #
REPLY 
I was curious to know when to use which model? And conditions to be met before
using a model. Can I get some points on this?
Jason Brownlee August 1, 2020 at 6:12 am #
REPLY 
Determine if you have multiple or single inputs and/or multiple or single outputs then
select a model that supports your requirements.
Gaurav August 2, 2020 at 12:14 am #
REPLY 
As far as I understand
Single input : Univariate Model
Multiple Input : Multivariate Model
But I guess where each of the models, in which scenario fits exceeds the scope of
this topic i.e cheat sheet.
However in short words(since I am a beginner to time-series) can you tell me where
each of these model fit in what scenario, so I can have a basic understanding of
where to use each model.
However I am having IoT data project in my company. where you get to see
monitored data in timestamp. I am being asked to make Pv predictions. Can you
suggest a model as well that would be great :
Datetime Pv Min Max Avg
01-01-2019 07:00 20.1 20.1 20.1 20.1
01-01-2019 07:03 20 20 20 20
Jason Brownlee August 2, 2020 at 5:47 am #
REPLY 
Yes, the example for each model show’s the type of example where it is
appropriate.
Rachel August 10, 2020 at 1:00 pm #
REPLY 
Hi, I am trying to work on sarimax but I am still confused on how to set the order and
seasonal order?
Jason Brownlee August 10, 2020 at 1:38 pm #
REPLY 
Use a grid search:
https://machinelearningmastery.com/how-to-grid-search-sarima-model-hyperparametersfor-time-series-forecasting-in-python/
Ei Ei Mon August 10, 2020 at 9:28 pm #
REPLY 
Hi Sir,
Thanks for your great tutorial.
Are there any other references for multivariate time-series forecasting with ARIMA and other
classical time-series approaches?
Thanks in advance.
Jason Brownlee August 11, 2020 at 6:31 am #
REPLY 
The above VAR methods are a good place to start.
Ajay Tiwari August 13, 2020 at 5:28 pm #
REPLY 
Hi Jason,
I have a question on lag orders, in case of univariate techniques, we can decide p and q
values using autocorrelation and partial autocorrelation. But, in the case of multivariate
techniques like VAR, VMA, and VARMA how we can decide these lag orders as we have
multiple parallel series?
Thanks,
Ajay
Jason Brownlee August 14, 2020 at 5:58 am #
REPLY 
It can get tricky. Perhaps fall back to a grid search.
Bob August 14, 2020 at 2:02 am #
REPLY 
Hello Prof Brownlee
I really need help in respect to my work.
I am trying something on modelling structural breaks in futures and wants to try something
unique with Python.
How can you help me, I will like to get through with your email please
Jason Brownlee August 14, 2020 at 6:09 am #
REPLY 
This process may help you work through your project:
https://machinelearningmastery.com/start-here/#process
Eddie September 22, 2020 at 9:18 pm #
REPLY 
Hi Jason,
Can you demonstrate using Dynamic Regression model? I need help with Dynamic
Regression model for my project.
where nt is ARMA process
yt = a + ν(B)xt + nt
Thank you so much for all your great tutorials.
Jason Brownlee September 23, 2020 at 6:38 am #
Thanks for the suggestion.
REPLY 
Eddie September 24, 2020 at 12:09 am #
REPLY 
Thanks Jason. Here is Rob’s link. Appreciate if you can do it in python.
https://robjhyndman.com/uwa2017/3-2-Dynamic-Regression.pdf
Jason Brownlee September 24, 2020 at 6:15 am #
REPLY 
Thanks for the suggestion.
Reza September 29, 2020 at 10:54 pm #
REPLY 
Hi Jason
Thank you for the great post.
I have a time series showing departure date, booking date and number of booked
passengers. It has both trend and seasonal components and I am working on passengers
forecast by considering departure week day, week, month and prior days ( departure date
minus booking date). What is your model suggestion to implement? MLP?
thanks
Jason Brownlee September 30, 2020 at 6:33 am #
REPLY 
I recommend testing a suite of different data preparation methods, different
modeling algorithms and different configurations in order to discover what works best for
your dataset:
https://machinelearningmastery.com/how-to-develop-a-skilful-time-series-forecastingmodel/
Kingsley Udeh October 1, 2020 at 8:11 pm #
Hi Dr. Jason,
REPLY 
I have a multivariate time seies problem formulation that seeks to forecast endogenous
variable y, as a function of exogenous variables, x1,x2,…,xn. I thought VARMAX method is
applicable in this situation, but it seems VARMAX() can only take multiple exogenous
varaibles when I tried to implement the method. However, one edogenous or response
variable is needed in my case.
I need to create a baseline model for the stated multivariate problem. I will appreciate your
thought in this situation.
Jason Brownlee October 2, 2020 at 5:58 am #
REPLY 
Perhaps you can use a persistence model as the baseline.
Then maybe use a linear regression model on window transform of the data as a baseline
linear model.
Kingsley Udeh October 2, 2020 at 7:56 am #
REPLY 
Thanks, Dr. Jason.
I undertand the aspect of the persistence model that would based on univariate data –
the respose variable.
For the second option, I guess you meant fiting a linear regression model on a
suppervised learning(window) transform of the response variablle, right?
Jason Brownlee October 2, 2020 at 8:12 am #
REPLY 
Yes, this can help you prepare the data:
https://machinelearningmastery.com/time-series-forecasting-supervised-learning/
And this:
https://machinelearningmastery.com/convert-time-series-supervised-learningproblem-python/
Kingsley Udeh October 2, 2020 at 10:14 pm #
Thanks!
REPLY 
Kingsley Udeh October 1, 2020 at 10:07 pm #
Revised: “multiple endogenous variables”
Hi Dr. Jason,
I have a multivariate time seies problem formulation that seeks to forecast endogenous
variable y, as a function of exogenous variables, x1,x2,…,xn. I thought VARMAX method is
applicable in this situation, but it seems VARMAX() can only take multiple endogenous
varaibles when I tried to implement the method. However, one edogenous or response
variable is needed in my case.
I need to create a baseline model for the stated multivariate problem. I will appreciate your
thought in this situation.
REPLY 
Jimmy October 5, 2020 at 8:50 pm #
Hello Dr. Jason,
I’m a trainee and are now executing my literature review with the goal to find the right method
for solving my internship problem. During my search for relevant articles I come across a lot of
your blogs and read some of them to find the method suitable for my problem. However, I still
haven’t found it yet. Maybe you can direct me in the right way?
From the department demand planning at my internship organization I get a monthly forecast
of the amount of products (medical devices) that will be ordered. I have been instructed to
break this monthly forecast down in daily forecast. So, I’m looking for a (machine learning)
method that distributes the monthly forecast into daily buckets. Am I looking in the right
direction if I’m searching for Time Series forecasting algorithms? I find that a lot of these
algorithms can be used to determine the monthly forecast and not the distribution of the
monthly forecast into daily buckets.
Can you help me putting me in the right direction for searching algorithms for distribution?
Sorry if the description of my problem and question is a bit hazy
🙂
Already thanks for your time.,
Jimmy,
The netherlands
Jason Brownlee October 6, 2020 at 6:48 am #
REPLY 
I would recommend testing a suite of different algorithms on your problem in
order to discover what works.
Perhaps this framework will help:
https://machinelearningmastery.com/how-to-develop-a-skilful-time-series-forecastingmodel/
Mohammed October 6, 2020 at 7:57 am #
REPLY 
Thank you for sharing all of these time series examples. I would like to do a weighted
time series forecast similar to Holt Winter’s Exponential Smoothing but with multivariate data.
What would you recommend for this? The objective is to have a time series forecast with
greater weight to more recent data
Jason Brownlee October 6, 2020 at 8:02 am #
REPLY 
The model will learn we weighting required to give the best forecast. No need to
do this manually.
Mohammed October 6, 2020 at 8:14 am #
REPLY 
Thanks what about in the extreme case now with Covid where there are only
several months of post-Covid data vs years of less useful historic data?
Jason Brownlee October 6, 2020 at 11:09 am #
REPLY 
No difference.
Valdemar Sousa October 15, 2020 at 4:32 am #
REPLY 
hi Jason, How can Time Series Analysis be done with Categorical Variables?
Right now I’m doing a project where I have a database of network infrastructure alames in a
space of 3 months, in this case a time series problem.
Most of the time series analysis tutorials/textbooks I’ve read about, be they for univariate or
multivariate time series data, usually deal with continuous numerical variables.
I currently have a problem at hand that deals with multivariate time series data, but the fields
are all categorical variables. Hence, I was wondering if there is any way to use the standard
time series analysis techniques (such as ARIMA, ARMA etc.)
Specifically, my data is a stream of alert data, where at each time stamp, information such as
the alert monitoring system, the location of the problem etc. are stored in the alert. These
fields are all categorical variables.
What advice can you give me regarding the problem, and which ML algorithms are most
recommended for this case?
Jason Brownlee October 15, 2020 at 6:20 am #
REPLY 
Encode them as numbers, then use any model you like, e.g. linear, machine
learning, deep learning, etc.
Popular methods include ordinal encoding, one hot encoding, embedding.
Rajiv Kamrani October 21, 2020 at 4:23 am #
Hi Dr Jason,
I want to do forecasting of telecom data.
The timeseries data has records in millions ranging from 1 million to 10 million.
Should i first normalize the timeseries data using log, min-max or any other method ?
REPLY 
Also, is it better to remove/replace outliers in time series data ?
Thanks & Regards,
Rajiv Kamrani
Jason Brownlee October 21, 2020 at 6:44 am #
REPLY 
Perhaps work with a small sample of the data.
It can be a good idea to scale, transform data, remove outliers, etc. try it and see if it
improves model performance.
Royal T. November 19, 2020 at 4:35 am #
REPLY 
Hi Jaron, there seems to be a bug in your SARIMA example, we get at line
model = SARIMAX(data, order=(1, 1, 1), seasonal_order=(1, 1, 1, 1))
Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\User\AppData\Local\Continuum\anaconda3\envs\Py37_Tf2_Ke2\lib\sitepackages\statsmodels\tsa\statespace\sarimax.py”, line 332, in __init__
missing=missing, validate_specification=validate_specification)
File “C:\Users\User\AppData\Local\Continuum\anaconda3\envs\Py37_Tf2_Ke2\lib\sitepackages\statsmodels\tsa\arima\specification.py”, line 303, in __init__
raise ValueError(‘Seasonal periodicity must be greater’
ValueError: Seasonal periodicity must be greater than 1.
Jason Brownlee November 19, 2020 at 7:50 am #
REPLY 
I can confirm the code operates correctly, I just re-ran it.
I have some suggestions for you:
https://machinelearningmastery.com/faq/single-faq/why-does-the-code-in-the-tutorial-notwork-for-me
Sourabh Shrikrishna Chinchanikar January 6, 2021 at 2:45 am #
REPLY 
Hi Jason,
Thank you for sharing all types of time series examples.
In my project work I want to predict vehicle speed considering different inputs such as current
speed of vehicle, traffic light states, distance between two vehicles etc. Which approach shall I
follow as it has trends and seasonality? its kind of multiple input and singe output scenario.
Thank you!!
Jason Brownlee January 6, 2021 at 6:31 am #
REPLY 
You’re welcome.
I recommend testing a suite of different algoritms in order to discover what works well or
best for your specific dataset.
Sourabh Shrikrishna Chinchanikar January 7, 2021 at 6:40 am #
REPLY 
Thanks for your reply. Can I implement SARIMA for multiple imput and single
output or do I have to use VAR or VARMA?
Jason Brownlee January 7, 2021 at 9:40 am #
REPLY 
Yes, it would be SARIMAX and additional input would be considered
exogenous input variables.
Vermi January 6, 2021 at 4:08 pm #
REPLY 
Hi Jason
Thank for the tutorial. I read your book on time series forecasting. Usually, time column is
dropped and then, train and test the model. In my work i want to predict the “time”. So i can’t
remove “time” column. The time is represented as “timestamp”. Can you please explain me
well how to preprocess the data in order to forecast the “time”.
I know how to prepare the data and split the dataset, it’s well explained in your book
Cordially,
Jason Brownlee January 7, 2021 at 6:15 am #
REPLY 
Thanks.
Perhaps you can frame it as a classification ask, e.g. will an event occur in the next time
step: 0 or 1.
JG February 6, 2021 at 5:23 am #
REPLY 
Hi Jason:
Interesting classical tutorials (via statistics analysis) that many times are better than advance
Neural ML models such as MLP, LSTM.
But this “statsmodels” library are not uniform on its terminology methods for each type of
model, sometimes requiring “.predict()” but other times requiring “.forecast( )”, with different
arguments on it (sometimes limits of length prediction, sometimes needing to declare the
variable to predict (but other not) …so not uniformity on them on the contrary when you use
Keras methods you know which arguments to declare.
in addition to it the exogenous variables as far I understand you need to provide on both
model definition and the “.predict()” methods…but at the end the prediction is for one feature
(univariate) but on multivariate are so many outputs as multivariate.
Also when you use multivariate models (VAR, VARMA,..) you also get multiple output (as
many as multivariate) … I thought you can uses to two features timeseries to produce a
complete new one output timeseries …as i thought it is allowed on keras MLP, LSTM, etc…So
my intuition fail
🙁
The terminology for orders (p,d,q..P,Q,D, mm) it is also confused. I think finally they refer to
lags o timesteps required for each order …
Jason Brownlee February 6, 2021 at 5:59 am #
REPLY 
Astute observations!
Agreed, the library has been a bit of a mess for years.
Cesar Zuge March 23, 2021 at 11:45 am #
REPLY 
Hello Jason,
Do you have any updated book about classical methods on python? As mentioned,
statsmodels are a mess through the years and in my university project i want to use
Simplexponentialsmooth, Holtwinters and ARIMA to predict my data but i’m having a lot of
problems about statsmodels.
A new library can help a lot as well
Jason Brownlee March 24, 2021 at 5:47 am #
REPLY 
I do cover SARIMAX and ETS in this book:
https://machinelearningmastery.com/deep-learning-for-time-series-forecasting/
Rupesh S March 24, 2021 at 1:49 am #
REPLY 
1) how to check stationarity for multivariate time series analysis and if i use
‘Johansen test’ for multivariate time series how i conclude the results.
2)can you please update here if you have python code for johansen test or any other test is
there to check stationarity for multivariate?
3) can i use ACF & PACF values for VARMAX models or it is only supports for univariate
models.
Jason Brownlee March 24, 2021 at 5:52 am #
REPLY 
Sorry, I cannot help you with these questions, I don’t have tutorials on these
topics.
CHIRAG GUPTA April 16, 2021 at 4:40 am #
REPLY 
I am working in petrochemical sector and want to forecast the production of ethylene
in cracker furnace based upon certain no. of chemical parameters like pressure, temperature
,composition of the gas with time, which models should I try to use, like LSTMs or classical
time series methods?
Jason Brownlee April 16, 2021 at 5:33 am #
REPLY 
Perhaps try a suite of techniques and discover what works well or best for your
specific dataset.
Abderrahmane May 22, 2021 at 12:48 am #
REPLY 
How can we use each of the 11 methods? I mean under what circumstances or
conditions should one apply AR, MA, ARMA, ARIMA, or SARIMA method.
Jason Brownlee May 22, 2021 at 5:33 am #
REPLY 
Each section gives some small idea of when to use it, e.g. when you have a
trend or seasonality or exog variable, etc.
Rainer Mokros July 8, 2021 at 10:17 pm #
Hey Jason,
One question wavelets are getting a hot topic.
You have anything on this topic
REPLY 
Jason Brownlee July 9, 2021 at 5:08 am #
REPLY 
Not at this stage.
Federica F. July 10, 2021 at 7:10 am #
REPLY 
Doctor Brownlee, good morning.
Thank you very much for the books you have written and the publications you make.
I was wondering if you know any library or function that calculates the best values for the
parameters (order and seasonal_orden), when using SARIMAX.
Thank you.
Jason Brownlee July 11, 2021 at 5:36 am #
REPLY 
You can use a grid search, see this example:
https://machinelearningmastery.com/how-to-grid-search-sarima-model-hyperparametersfor-time-series-forecasting-in-python/
Federica F. July 11, 2021 at 11:19 am #
REPLY 
Doctor thank you very much!
Jason Brownlee July 12, 2021 at 5:46 am #
REPLY 
You’re welcome.
Anjali July 22, 2021 at 4:01 pm #
Thank You for the post
REPLY 
Jason Brownlee July 23, 2021 at 5:49 am #
REPLY 
You’re welcome.
FV July 22, 2021 at 7:28 pm #
REPLY 
Hello Jason,
I have to backcast values of a time series. Is it enough to invert the time series and procede
with forecasting?
I was wondering if there is some python code related to backcasting.
Thank you.
Jason Brownlee July 23, 2021 at 5:58 am #
REPLY 
Perhaps try a few methods and discover what works well or bes. Compare
everything to simple persistence model.
Leave a Reply
Name (required)
Email (will not be published) (required)
Website
SUBMIT COMMENT
© 2021 Machine Learning Mastery Pty. Ltd. All Rights Reserved.
LinkedIn | Twitter | Facebook | Newsletter | RSS
Privacy | Disclaimer | Terms | Contact | Sitemap | Search
PDFmyURL.com - convert URLs, web pages or even full websites to PDF online. Easy API for developers!
Download