Book Image

Machine Learning for Time-Series with Python - Second Edition

By : Ben Auffarth
4 (4)
Book Image

Machine Learning for Time-Series with Python - Second Edition

4 (4)
By: Ben Auffarth

Overview of this book

The Python time-series ecosystem is a huge and challenging topic to tackle, especially for time series since there are so many new libraries and models. Machine Learning for Time Series, Second Edition, aims to deepen your understanding of time series by providing a comprehensive overview of popular Python time-series packages and helping you build better predictive systems. This fully updated second edition starts by re-introducing the basics of time series and then helps you get to grips with traditional autoregressive models as well as modern non-parametric models. By observing practical examples and the theory behind them, you will gain a deeper understanding of loading time-series datasets from any source and a variety of models, such as deep learning recurrent neural networks, causal convolutional network models, and gradient boosting with feature engineering. This book will also help you choose the right model for the right problem by explaining the theory behind several useful models. New updates include a chapter on forecasting and extracting signals on financial markets and case studies with relevant examples from operations management, digital marketing, and healthcare. By the end of this book, you should feel at home with effectively analyzing and applying machine learning methods to time series.
Table of Contents (3 chapters)

Historical Development of Time Series Applications

An early work in time series analysis was The Art of Statistics, published in 1833 by Adolphe Quetelet. The first general work on time series analysis is generally credited to Francis Galton and his work Natural Inheritance, published in 1889. A significant contribution to the development of time series analysis was made by the statistician and biologist Ronald Fisher in his work Statistical Methods for Research Workers, published in 1925.Classical time series modeling approaches were introduced by George Box and Gwilym Jenkins in 1970 in their book "Time-Series Analysis Forecasting and Control." Most importantly, they formalized the ARIMA and ARMAX models and described how to apply them to time series forecasting. We'll talk about these types of models in Chapter 5, Forecasting with Moving Averages and Autoregressive Models.The study of time series in different scientific disciplines was foundational to fields such as demography, astronomy, medicine, and economics. We won't cover all these fields, but just give a few highlights, especially from astronomy and meteorology, which are particularly interesting cases for their development.

Astronomy

Observations of comets and asteroids, and the and the movements of the sun and the planets have been recorded for a long time, and people have been studying these records to understand the regularities and relationships of these movements and our place in the universe. For example, the Greek historian Herodotus wrote about the effects of the solar eclipse on the battle of Halicarnassus.One of the first modern scientific prediction of the future was made by Isaac Newton in a letter to Richard Bentley, who later published it in 1693 as A Letter of Mr. Isaac Newton, Containing his Natural Philosophy: Together with Translations from the Original Latin and French Versions; and a Commentary on his Work, Philosophiae Naturalis Principia Mathematica. In the letter, Newton predicts that the end of the world will take place in 2060.In the first paragraph of the letter, Newton correctly identifies five major problems in physics: motion, light, heat, magnetism, and gravity. He also correctly states that they can all be explained by the same principles. He goes on to say that the principles can be discovered by induction, which is the process of generalizing from specific observations to a general law. In the second paragraph, Newton states that the laws of motion can be used to predict the future, and that the future can be predicted with great accuracy. He then gives an example of this, predicting that the end of the world will take place in 2060.Although Newton's prediction was not accurate, it did demonstrate the potential of using scientific methods to understand the world around us and making predictions.Not much after Newton, in 1801, Carl Friedrich Gauss devised a method for determining the orbit of the dwarf planet Ceres. Ceres orbits in the asteroid belt between Mars and Jupiter. The German polymath's method was based on observations of a Catholic priest and astronomer, Giuseppe Piazzi, who traced an object between January and February 1801. Gauss then applied his method to the observations and used the results to predict where Ceres would be located on December 31, 1801. Ceres was discovered on the predicted date and location.Many discoveries in astronomy have been made recently. In 1978, an American astronomer, James Christy, discovered Pluto's largest moon. Christy used the U.S. Naval Observatory's telescope in Flagstaff, Arizona, to make the discovery. Time series images of Pluto showed that the dwarf planet's brightness varied by about 0.1% over a 6.4-hour period. This suggested that an object half the size of Pluto was orbiting it. Christy named the new object "Charon'' after the boatman who ferries souls across the River Styx in Greek mythology. Michael Brown and Chad Trujillo used similar techniques to discover a faint object beyond Neptune that they named Eris, today classified as a dwarf planet.New discoveries of dwarf planets and exoplanets are being made every year using new instruments and statistical approaches.

Meteorology

The modern science of meteorology has its roots in ancient times as well. The Babylonians are thought to have had some rudimentary knowledge about atmospheric processes, and they are known to have observed and recorded the regular ebb and flow of the tides.The Greek philosopher Aristotle was one of the first to write about weather and its measurement; however, it took much longer for the first weather predictions to be made. Vice Admiral Robert FitzRoy founded the United Kingdom's national weather service, the Meteorological Office, in 1854. FitzRoy had already reserved his place in history as the captain of the HMS Beagle, the ship that carried a recently graduated naturalist by the name of Charles Darwin around the world. It was FitzRoy, in fact, who coined the word forecast, although at the time, many contemporaries referred to them as "quack weather prognostications".The first computerized weather models were programmed on the Electronic Numerical Integrator and Computer (ENIAC). The ENIAC, designed by John Mauchly and J. Presper Eckert, could run arbitrary sequences of operations; however, it didn't read the programs from tapes but from plugboard switches. The giant 15x9-meter machine is exhibited today at the Smithsonian Institute in Washington, D.C. Consisting of 17,500 vacuum tubes, it first produced calculations for the construction of a hydrogen bomb and was then exploited to extend forecasting past one or two days using new methods of numerical weather prediction. The computer was programmed by Klara von Neumann.Here's a photo of the ENIAC (source: Wikimedia Commons):

Figure 1.6: Electronic Numerical Integrator and Computer (ENIAC)

You can see Betty Snyder, one of the earliest programmers of the ENIAC, standing in front of the ENIAC.Later, Joseph Smagorinsky and Douglas Lilly developed a mathematical model for turbulence used in computational fluid dynamics. This model, the Smagorinsky-Lilly model, which is still in use today, used data about the wind, cloud cover, precipitation, atmospheric pressure, and radiation emanating from the earth and sun as input. Smagorinsky continued to lead research on global warming, investigating the climate's sensitivity to increasing carbon dioxide levels.The introduction of mobile sensor arrays and computerized models has greatly increased the accuracy of weather predictions. Valuable temperature and wind data is collected by sensors deployed by meteorology offices or other sources, most importantly by commercial aircraft as they fly. Today, within a seven-day window, a forecast is accurate about 80% of the time. The grounding of commercial flights during the COVID pandemic, where there were about 75% fewer flights for some periods, has led to less accurate forecasts recently.DeepMind, a Google subsidiary, is working on artificial intelligence (AI) models to predict the weather. The technology could improve the accuracy of predictions by up to 50%.DeepMind’s AI model uses a neural network architecture called a recurrent neural network (RNN). It takes advantage of the fact that the weather depends on past weather patterns. A deep learning algorithm is trained on historical data to predict the weather. DeepMind’s AI model is able to predict weather patterns over a five-day period. The neural network is trained on 30 years of weather data from the United States’ Global Forecast System (GFS) weather model.