Ultralytics YOLO27: Join the waitlist.
License YOLO
Back to Ultralytics Glossary

Time Series Analysis

Time series analysis studies time-ordered data to find trends, seasonality, and anomalies and to forecast future values with statistical and deep models.

Time series analysis is the study of data points recorded in time order, usually at regular intervals, such as hourly sensor readings, daily sales, or the number of vehicles a traffic camera sees each minute. What sets it apart from other data analytics is that order carries information: each observation depends on the ones before it, so shuffling the data destroys the patterns of interest. The main goals are describing a series through its trend and seasonal patterns, forecasting future values, detecting anomalies, and classifying whole series, such as heart rhythms in an ECG.

Trend, Seasonality, and Stationarity#

Most series combine a few components. The trend is the long-term direction, seasonality is a pattern that repeats over a fixed period such as a day, week, or year, cycles are longer rises and falls without a fixed period, and the residual is what remains. Decomposition separates them, classically with moving averages and more robustly with STL, the seasonal-trend decomposition based on local regression that Robert Cleveland and colleagues published in 1990.

Autocorrelation, the correlation of a series with a lagged copy of itself, exposes this structure: a strong value at lag 24 in hourly data means each hour resembles the same hour a day earlier. Many statistical models also assume stationarity, meaning the mean, variance, and autocorrelation do not change over time. The augmented Dickey-Fuller test checks for a common form of non-stationarity, and differencing, which models the change from one step to the next instead of the level, removes a trend.

This example simulates four weeks of hourly vehicle counts with a daily cycle, a slow upward trend, and noise, measures its autocorrelation, and forecasts the last day two ways:

import numpy as np
import pandas as pd

# Four weeks of hourly vehicle counts: a daily cycle, a slow upward trend, and noise
rng = np.random.default_rng(0)
hours = pd.date_range("2026-03-01", periods=24 * 28, freq="h")
daily_cycle = 40 + 30 * np.sin(2 * np.pi * (hours.hour - 9) / 24)
counts = pd.Series(daily_cycle + 0.02 * np.arange(len(hours)) + rng.normal(0, 5, len(hours)), index=hours)

# Autocorrelation: how strongly each count resembles the count 1, 12, and 24 hours earlier
for lag in [1, 12, 24]:
    print(f"Autocorrelation at lag {lag}: {counts.autocorr(lag):.2f}")

# Forecast the final day from the 27 days before it
history, actual = counts[:-24], counts[-24:].to_numpy()
naive = np.full(24, history.iloc[-1])  # repeat the last observed count
seasonal_naive = history.iloc[-24:].to_numpy()  # repeat the same hour of the previous day
print(f"Naive MAE: {np.abs(actual - naive).mean():.1f} vehicles")
print(f"Seasonal naive MAE: {np.abs(actual - seasonal_naive).mean():.1f} vehicles")

The autocorrelation is 0.92 at lag 1, -0.89 at lag 12, where the afternoon peak lines up with the night low, and 0.95 at lag 24. Repeating the last observed count misses by 24.5 vehicles per hour on average, while repeating the previous day misses by 5.6, so the seasonal naive forecast is the baseline a forecasting model has to beat.

Forecasting Methods#

Statistical methods remain strong, especially for short series. Exponential smoothing, developed by Charles Holt and Peter Winters around 1960, weights recent observations most and adds trend and seasonal terms. ARIMA models, popularized by George Box and Gwilym Jenkins in 1970, combine autoregression, differencing, and moving averages of past errors. Meta's Prophet fits trend, seasonality, and holiday effects for business data.

Machine learning models treat forecasting as predictive modeling on lagged values and calendar features. Gradient-boosted trees such as LightGBM dominated the 2020 M5 competition on Walmart sales, while the 2018 M4 competition, with 100,000 series, was won by Slawek Smyl's hybrid of exponential smoothing and a recurrent neural network. Deep learning models include LSTMs, state space models, and transformers, and pretrained foundation models such as Amazon's Chronos and Google's TimesFM forecast new series zero-shot. Kalman filters cover the related task of estimating a hidden state, such as an object's position, from noisy measurements in real time.

Evaluation must respect time. Random cross-validation lets a model see the future, a form of data leakage, so forecasts are tested with rolling-origin evaluation, which trains on everything before a cutoff, predicts the period after it, and repeats as the cutoff moves forward.

Time Series From Video#

Computer vision turns video into time series. Object counting on a traffic camera produces vehicles per minute, object tracking produces positions and speeds per frame, and store cameras produce occupancy counts per hour. These series then feed the same methods: forecasting rush hours or staffing needs, and anomaly detection that flags a sudden drop in traffic after an accident. In the Ultralytics Analytics solution, analytics_type="line" tracks objects with a YOLO26 model and plots the number of objects in view every 30 frames, about once per second for 30 fps video, so a camera feed becomes a count series as it plays.

Time series analysis overlaps with sequence modeling in natural language processing, where text is ordered by position and has no sampling interval. Counts and speeds extracted from video by detection, tracking, and video understanding models take far less space than the frames, so years of them can be stored and compared across cameras.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning