Machine Learning for Time-Series with Python

By Ben Auffarth
    What do you get with a Packt Subscription?

  • Instant access to this title and 7,500+ eBooks & Videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Free Chapter
    Time-Series Analysis with Python
About this book

The Python time-series ecosystem is huge and often quite hard to get a good grasp on, especially for time-series since there are so many new libraries and new models. This book aims to deepen your understanding of time series by providing a comprehensive overview of popular Python time-series packages and help you build better predictive systems.

Machine Learning for Time-Series with Python starts by re-introducing the basics of time series and then builds your understanding of traditional autoregressive models as well as modern non-parametric models. By observing practical examples and the theory behind them, you will become confident with loading time-series datasets from any source, deep learning models like recurrent neural networks and causal convolutional network models, and gradient boosting with feature engineering.

This book will also guide you in matching the right model to the right problem by explaining the theory behind several useful models. You’ll also have a look at real-world case studies covering weather, traffic, biking, and stock market data.

By the end of this book, you should feel at home with effectively analyzing and applying machine learning methods to time-series.

Publication date:
October 2021


Introduction to Time-Series with Python

This book is about machine learning for time-series with Python, and you can see this chapter as a 101 class for time-series. In this chapter, we'll introduce time-series, the history of research into time-series, and how to use Python for time-series.

We'll start with what a time-series is and its main properties. We'll then look at the history of the study of time-series in different scientific disciplines foundational to the field, such as demography, astronomy, medicine, and economics.

Then, we'll go over the capabilities of Python for time-series and why Python is the go-to language for doing machine learning with time-series. Finally, I will describe how to install the most prominent libraries in Python for time-series analysis and machine learning, and we'll cover the basics of Python as relevant to time-series and machine learning.

We're going to cover the following topics:


What Is a Time-Series?

Since this is a book about time-series data, we should start with a clarification of what we are talking about. In this section, we'll introduce time-series and their characteristics, and we'll go through different kinds of problems and types of analyses relevant to machine learning and statistics.

Many disciplines, such as finance, public administration, energy, retail, and healthcare, are dominated by time-series data. Large areas of micro- and macro-economics rely on applied statistics with an emphasis on time-series analyses and modeling. The following are examples of time-series data:

  • Daily closing values of a stock index
  • Number of weekly infections of a disease
  • Weekly series of train accidents
  • Rainfall per day
  • Sensor data such as temperature measurements per hour
  • Population growth per year
  • Quarterly earnings of a company over a number of years

This is only to name but a few. Any data...


Time-Series and Forecasting – Past and Present

Time-Series have been studied since antiquity, and since then, time-series analysis and forecasting have come a long way. A variety of disciplines contributed to the development of techniques applied to time-series, including mathematics, astronomy, demographics, and statistics. Many innovations came initially from mathematics, later statistics, and finally machine learning. Many innovations in applied statistics had their origins in demography (used in public administration), economics, or other fields.

In this section, I'll sketch the development path from simpler methods leading up to the machine learning methods available today. I'll try to chart the development of concepts relevant to time-series from the time of the Industrial Revolution to modernity. We'll deal with the more technical and up-to-date side of things in Chapter 4, Introduction to Machine Learning with Time-Series.

There's still much...


Python for Time-Series

For time-series, there are two main languages, R and Python, and it's worth briefly comparing the two and describing what makes Python special. Python is one of the top programming languages by popularity. According to the TIOBE from February 2021, it is only surpassed in popularity by C and Java.

















In this chapter, we've introduced time-series, the history of research into time-series, and Python for time-series.

We started with a definition of time-series and its main properties. We then looked at the history of the study of time-series in different scientific disciplines, such as demography and genetics, astronomy, economics, meteorology, medicine, and applied statistics.

Then, we went over the capabilities of Python for time-series and why Python is the go-to language for doing machine learning with time-series. Finally, I described how to install and use Python for time-series analysis and machine learning, and we covered some of the basics of Python as relevant to time-series and machine learning.

In the next chapter, we'll look at time-series analysis with Python.

About the Author
  • Ben Auffarth

    Ben Auffarth is a full-stack data scientist who has >15 years of work experience. With a background and Ph.D. in computational and cognitive neuroscience from one of Europe's top engineering universities, he has designed and conducted wet lab experiments on cell cultures, analyzed experiments with terabytes of data, run brain models on IBM supercomputers with up to 64k cores, built production systems processing hundreds of thousands of transactions per day, and trained neural networks on millions of text documents. In his work, he often notices a lack of appreciation for the importance of time-related factors, a deficit he wanted to address in this book. He co-founded and is the former president of Data Science Speakers, London.

    Browse publications by this author
Machine Learning for Time-Series with Python
Unlock this book and the full library FREE for 7 days
Start now