What Is Time Series Forecasting?

Time series forecasting is an important area of machine learning that is often neglected.

It is important because there are so many prediction problems that involve a time component. These problems are neglected because it is this time component that makes time series problems more difficult to handle.

In this post, you will discover time series forecasting.

After reading this post, you will know:

  • Standard definitions of time series, time series analysis, and time series forecasting.
  • The important components to consider in time series data.
  • Examples of time series to make your understanding concrete.

Let’s get started.

What is Time Series Forecasting?

What is Time Series Forecasting?
Photo by Dennis Kleine, some rights reserved.

Time Series

A normal machine learning dataset is a collection of observations.

For example:

Time does play a role in normal machine learning datasets.

Predictions are made for new data when the actual outcome may not be known until some future date. The future is being predicted, but all prior observations are almost always treated equally. Perhaps with some very minor temporal dynamics to overcome the idea of “concept drift” such as only using the last year of observations rather than all data available.

A time series dataset is different.

Time series adds an explicit order dependence between observations: a time dimension.

This additional dimension is both a constraint and a structure that provides a source of additional information.

A time series is a sequence of observations taken sequentially in time.

— Page 1, Time Series Analysis: Forecasting and Control.

For example:

Describing vs. Predicting

We have different goals depending on whether we are interested in understanding a dataset or making predictions.

Understanding a dataset, called time series analysis, can help to make better predictions, but is not required and can result in a large technical investment in time and expertise not directly aligned with the desired outcome, which is forecasting the future.

In descriptive modeling, or time series analysis, a time series is modeled to determine its components in terms of seasonal patterns, trends, relation to external factors, and the like. … In contrast, time series forecasting uses the information in a time series (perhaps with additional information) to forecast future values of that series

— Page 18-19, Practical Time Series Forecasting with R: A Hands-On Guide.

Time Series Analysis

When using classical statistics, the primary concern is the analysis of time series.

Time series analysis involves developing models that best capture or describe an observed time series in order to understand the underlying causes. This field of study seeks the “why” behind a time series dataset.

This often involves making assumptions about the form of the data and decomposing the time series into constitution components.

The quality of a descriptive model is determined by how well it describes all available data and the interpretation it provides to better inform the problem domain.

The primary objective of time series analysis is to develop mathematical models that provide plausible descriptions from sample data

— Page 11, Time Series Analysis and Its Applications: With R Examples

Time Series Forecasting

Making predictions about the future is called extrapolation in the classical statistical handling of time series data.

More modern fields focus on the topic and refer to it as time series forecasting.

Forecasting involves taking models fit on historical data and using them to predict future observations.

Descriptive models can borrow for the future (i.e. to smooth or remove noise), they only seek to best describe the data.

An important distinction in forecasting is that the future is completely unavailable and must only be estimated from what has already happened.

The purpose of time series analysis is generally twofold: to understand or model the stochastic mechanisms that gives rise to an observed series and to predict or forecast the future values of a series based on the history of that series

— Page 1, Time Series Analysis: With Applications in R.

The skill of a time series forecasting model is determined by its performance at predicting the future. This is often at the expense of being able to explain why a specific prediction was made, confidence intervals and even better understanding the underlying causes behind the problem.

Stop learning Time Series Forecasting the slow way

Sign-up and get a FREE 7-day Time Series Forecasting Mini-Course

You will get:
...one lesson each day delivered to your inbox
...exclusive PDF ebook containing all lessons
...confidence and skills to work through your own projects

Download Your FREE Mini-Course

Components of Time Series

Time series analysis provides a body of techniques to better understand a dataset.

Perhaps the most useful of these is the decomposition of a time series into 4 constituent parts:

  1. Level. The baseline value for the series if it were a straight line.
  2. Trend. The optional and often linear increasing or decreasing behavior of the series over time.
  3. Seasonality. The optional repeating patterns or cycles of behavior over time.
  4. Noise. The optional variability in the observations that cannot be explained by the model.

All time series have a level, most have noise, and the trend and seasonality are optional.

The main features of many time series are trends and seasonal variations … another important feature of most time series is that observations close together in time tend to be correlated (serially dependent)

— Page 2, Introductory Time Series with R

These constituent components can be thought to combine in some way to provide the observed time series. For example, they may be added together to form a model as follows:

Assumptions can be made about these components both in behavior and in how they are combined, which allows them to be modeled using traditional statistical methods.

These components may also be the most effective way to make predictions about future values, but not always.

In cases where these classical methods do not result in effective performance, these components may still be useful concepts, and even input to alternate methods.

Concerns of Forecasting

When forecasting, it is important to understand your goal.

Use the Socratic method and ask lots of questions to help zoom in on the specifics of your predictive modeling problem. For example:

  1. How much data do you have available and are you able to gather it all together? More data is often more helpful, offering greater opportunity for exploratory data analysis, model testing and tuning, and model fidelity.
  2. What is the time horizon of predictions that is required? Short, medium or long term? Shorter time horizons are often easier to predict with higher confidence.
  3. Can forecasts be updated frequently over time or must they be made once and remain static? Updating forecasts as new information becomes available often results in more accurate predictions.
  4. At what temporal frequency are forecasts required? Often forecasts can be made at a lower or higher frequencies, allowing you to harness down-sampling, and up-sampling of data, which in turn can offer benefits while modeling.

Time series data often requires cleaning, scaling, and even transformation.

For example:

  • Frequency. Perhaps data is provided at a frequency that is too high to model or is unevenly spaced through time requiring resampling for use in some models.
  • Outliers. Perhaps there are corrupt or extreme outlier values that need to be identified and handled.
  • Missing. Perhaps there are gaps or missing data that need to be interpolated or imputed.

Often time series problems are real-time, continually providing new opportunities for prediction. This adds an honesty to time series forecasting that quickly flushes out bad assumptions, errors in modeling and all the other ways that we may be able to fool ourselves.

Examples of Time Series Forecasting

There is almost an endless supply of time series forecasting problems.

Below are 10 examples from a range of industries to make the notions of time series analysis and forecasting more concrete.

  • Forecasting the corn yield in tons by state each year.
  • Forecasting whether an EEG trace in seconds indicates a patient is having a seizure or not.
  • Forecasting the closing price of a stock each day.
  • Forecasting the birth rate at all hospitals in a city each year.
  • Forecasting product sales in units sold each day for a store.
  • Forecasting the number of passengers through a train station each day.
  • Forecasting unemployment for a state each quarter.
  • Forecasting utilization demand on a server each hour.
  • Forecasting the size of the rabbit population in a state each breeding season.
  • Forecasting the average price of gasoline in a city each day.

I expect that you will be able to relate one or more of these examples to your own time series forecasting problems that you would like to address.

Summary

In this post, you discovered time series forecasting.

Specifically, you learned:

  • About time series data and the difference between time series analysis and time series forecasting.
  • The constituent components that a time series may be decomposed into when performing an analysis.
  • Examples of time series forecasting problems to make these ideas concrete.

Do you have any questions about time series forecasting or about this post?
Ask your questions in the comments below.

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.

Click to learn more.

 

21 Responses to What Is Time Series Forecasting?

  1. Amit December 2, 2016 at 1:30 pm #

    Hi Jason,

    Is there a paper for this – Forecasting utilization demand on a server each hour? Would you be able to link it here?

    -Amit

  2. Leo December 2, 2016 at 6:38 pm #

    “Time series forecasting is an important area of machine learning that is often neglected.”

    Time series analysis is an area in itself. Many time series analysts will be offended by this sentence. No pun intended.

    • Brandon December 3, 2016 at 3:59 am #

      Maybe, but in the realm of machine learning time series is just a subset for analyzing and forecasting. If this were another type of blog, not machinelearningmastery, then maybe take offense.

    • Jason Brownlee December 3, 2016 at 8:27 am #

      Thanks for the feedback. Indeed Leo, time series is neglected when discussing machine learning. It is left out of most books.

  3. Saeed Ghasemi December 4, 2016 at 3:03 am #

    Thank you for this post. Interesting read.

    Can LSTMs be used for time series prediction? What performance could one expect relative to other neuron models and architecture? (e.g. RNN, CNN)

    • Jason Brownlee December 4, 2016 at 5:35 am #

      Yes, LSTMs can be used for time series, but they can be tricky to configure.

      I plan to do some large studies on LSTMs vs CNN and other methods in time series soon.

  4. Kleyn Guerreiro December 7, 2016 at 12:07 am #

    Nowadays I see that MARS (actually “earth” in R) is the strongest algorithm to forecast time series data.

    • Jason Brownlee December 7, 2016 at 8:56 am #

      Thanks for the tip Kleyn. I can see why it would be powerful, it’s a great method.

  5. Anthony Bailey December 16, 2016 at 11:48 pm #

    Hi Jason,
    I was wondering whether to specialize in time series or machine learning. What do you think which of these has a brighter future for someone interested in research in one of these two fields?
    Anthony

    • Jason Brownlee December 17, 2016 at 11:12 am #

      Sorry, I am not in touch with academia any longer.

      There are a lot of problems where machine learning can be helpful in industry and some of those problems are time series.

  6. Johno December 29, 2016 at 10:39 pm #

    Very nice article Jason. Do you think time series data analysis is as important as the machine learning problems in the industry?

    • Jason Brownlee December 30, 2016 at 5:50 am #

      Yes I do Johno, there are many problems with time series and unfortunately, many ML practitioners are unaware of standard methods like ARIMA.

  7. Raphael January 23, 2017 at 9:25 am #

    Do you have an introductory tutorial on time series analysis?

  8. Pooja Parmar February 17, 2017 at 5:19 pm #

    Hi Jason,

    Can you plz tell me from where I can find experiments like this “Forecasting the average price of gasoline in a city each day”?

    • Jason Brownlee February 18, 2017 at 8:35 am #

      Hi Pooja, I have not seen this specific example,

      You could collect the data and create the models, perhaps starting with one city and one year of data, then scaling up from there.

  9. Ranjana March 6, 2017 at 11:26 pm #

    Hello Jason,

    How do I predict increase/decrease in gas price based on historical data of different years using forecasting in machine learning?

  10. Kalongo March 16, 2017 at 7:35 pm #

    Hi Jason

    I want to do a study to compare which one is better when it comes to forecasting between time series models and machine learning models.

    How can you advise me to go about this study?

Leave a Reply