Chapter 1: What Is Time Series Forecasting? Definitions, Use Cases, and Core Value
> Picture this: You’re a regular at a small neighborhood coffee shop, and last week the owner, Sam, mentioned he’d overstocked on oat milk and coffee beans by 50% for the weekend after a rainy forecast, only to see foot traffic drop 40% lower than expected. He ended up donating most of the leftover perishables to a local food bank. The weekend before that, he’d understocked after a slow week, only to be caught off guard by a community block party that brought in triple his usual Saturday crowd, turning away dozens of customers before closing early. “If only I could know how many people will show up each day,” he sighed, “I’d never have to deal with wasted food or lost sales again.”
Sam’s frustration is a universal pain point for anyone who relies on anticipating future demand, usage, or behavior. Whether you’re a small business owner, a utility grid operator, a financial analyst, or a factory manager, the ability to accurately predict what will happen next is one of the most powerful tools you can have. This is the core of time series forecasting: the practice of using historical, time-stamped data to identify patterns and estimate future values. Over the course of this book, we will break down this seemingly complex field into simple, actionable steps, starting from foundational concepts and building up to both classical statistical methods and state-of-the-art deep learning models. By the end, you will be able to build, evaluate, and deploy your own forecasting models for real-world use cases, no advanced math or programming background required.
<!-- 纸书:本节对应P2-4 --> <!-- 标签:基础概念、定义、开篇引入 --> <!-- 电子版:可添加交互式咖啡店销售预测小游戏,链接:https://example.com/coffee-shop-forecast-game -->
What Is a Time Series and Time Series Forecasting?
To understand forecasting, we first need to define what a time series is. A time series is any sequence of observations collected in strict chronological order, where each observation is tied to a unique timestamp. The timestamp can be measured in any fixed interval: seconds (e.g., server CPU usage per minute), hours (e.g., hourly temperature readings), days (e.g., daily retail sales), weeks (e.g., weekly flu case counts), months (e.g., monthly unemployment rates), or even years (e.g., annual global carbon emissions). The key characteristic that distinguishes time series data from other types of data is its inherent time dependency: each observation is influenced by observations that came before it.
This time dependency is called autocorrelation (short for “autocorrelation”), a term we will revisit in detail in later chapters. For now, think of it as the “memory” of a time series: the number of customers at Sam’s coffee shop today is strongly correlated with the number of customers yesterday, and moderately correlated with the number of customers last Saturday, because people’s daily and weekly routines are relatively consistent. This autocorrelation is what makes it possible to predict future values from past data.
Time series forecasting is the process of extracting these stable, repeatable patterns from historical time series data, and using them to estimate values at future time points. The output of a forecasting model is not a single exact number, but a range of possible values (a forecast interval) paired with a measure of how confident the model is in its estimate. For example, a forecast for Sam’s weekend coffee sales might be “1,200 to 1,400 drinks, with 95% confidence,” rather than a single fixed number of 1,300 drinks.
It is important to distinguish time series forecasting from other types of prediction tasks you may have encountered. The most common comparison is with cross-sectional prediction: cross-sectional data collects observations from multiple entities at a single point in time, such as the 2024 annual revenue of all Fortune 500 companies. There is no time order in cross-sectional data, and the revenue of one company does not depend on the revenue of another. Time series data, by contrast, tracks a single metric (or entity) over time, with a strict chronological order that creates dependencies between observations. There is also a third common data type called panel data, which combines both dimensions: it tracks multiple entities over time,
> Picture this: You’re a regular at a small neighborhood coffee shop, and last week the owner, Sam, mentioned he’d overstocked on oat milk and coffee beans by 50% for the weekend after a rainy forecast, only to see foot traffic drop 40% lower than expected. He ended up donating most of the leftover perishables to a local food bank. The weekend before that, he’d understocked after a slow week, only to be caught off guard by a community block party that brought in triple his usual Saturday crowd, turning away dozens of customers before closing early. “If only I could know how many people will show up each day,” he sighed, “I’d never have to deal with wasted food or lost sales again.”
Sam’s frustration is a universal pain point for anyone who relies on anticipating future demand, usage, or behavior. Whether you’re a small business owner, a utility grid operator, a financial analyst, or a factory manager, the ability to accurately predict what will happen next is one of the most powerful tools you can have. This is the core of time series forecasting: the practice of using historical, time-stamped data to identify patterns and estimate future values. Over the course of this book, we will break down this seemingly complex field into simple, actionable steps, starting from foundational concepts and building up to both classical statistical methods and state-of-the-art deep learning models. By the end, you will be able to build, evaluate, and deploy your own forecasting models for real-world use cases, no advanced math or programming background required.
<!-- 纸书:本节对应P2-4 --> <!-- 标签:基础概念、定义、开篇引入 --> <!-- 电子版:可添加交互式咖啡店销售预测小游戏,链接:https://example.com/coffee-shop-forecast-game -->
What Is a Time Series and Time Series Forecasting?
To understand forecasting, we first need to define what a time series is. A time series is any sequence of observations collected in strict chronological order, where each observation is tied to a unique timestamp. The timestamp can be measured in any fixed interval: seconds (e.g., server CPU usage per minute), hours (e.g., hourly temperature readings), days (e.g., daily retail sales), weeks (e.g., weekly flu case counts), months (e.g., monthly unemployment rates), or even years (e.g., annual global carbon emissions). The key characteristic that distinguishes time series data from other types of data is its inherent time dependency: each observation is influenced by observations that came before it.
This time dependency is called autocorrelation (short for “autocorrelation”), a term we will revisit in detail in later chapters. For now, think of it as the “memory” of a time series: the number of customers at Sam’s coffee shop today is strongly correlated with the number of customers yesterday, and moderately correlated with the number of customers last Saturday, because people’s daily and weekly routines are relatively consistent. This autocorrelation is what makes it possible to predict future values from past data. You experience autocorrelation in daily life all the time: your commute time this morning is likely very similar to your commute time yesterday, and the amount of coffee you drink on Monday is probably close to what you drank last Monday. These consistent, time-bound patterns are the raw material for all forecasting work.
Time series forecasting is the process of extracting these stable, repeatable patterns from historical time series data, and using them to estimate values at future time points. The output of a forecasting model is not a single exact number, but a range of possible values (a forecast interval) paired with a measure of how confident the model is in its estimate. For example, a forecast for Sam’s weekend coffee