Time Series Forecasting
Time Series Forecasting
Predicting future values from past data. Used for stock prices and demand forecasting.
Time Series Forecasting
Predicting future values from past data. Used for stock prices and demand forecasting.
Time Series Forecasting is a machine learning/deep learning technique that analyzes historical data arranged in chronological order to estimate future values. It can be applied to any data that changes over time, such as stock prices, sales, temperature, and power demand, and is used as a core tool for business decision-making.
The history of time series analysis goes back to the Box-Jenkins ARIMA model in the 1970s, but since the emergence of the Transformer in 2017, deep learning-based forecasting has become mainstream. In particular, in 2024, Foundation Model-based time series forecasting models such as Google's TimesFM and Amazon's Chronos were commercialized, opening a new paradigm.
The core of time series forecasting is to learn patterns by decomposing a series into trend, seasonality, and residual components. The latest models receive multimodal inputs (text descriptions, external variables) together to improve forecasting accuracy, and can be applied immediately to new domains through zero-shot forecasting.
In practice, not only forecasting accuracy but also uncertainty quantification is important. As of 2025, Probabilistic Forecasting has become the standard, and it is used for risk management by providing confidence intervals and distributions rather than simple point forecasts.
# 시계열 예측 - Google TimesFM 활용 예제
# pip install timesfm
import numpy as np
import pandas as pd
from timesfm import TimesFM
# 모델 로드 (Google의 사전학습된 Foundation Model)
model = TimesFM.load_from_checkpoint("google/timesfm-1.0-200m")
# 예시 데이터: 일별 매출 데이터 (과거 365일)
dates = pd.date_range(start="2024-01-01", periods=365, freq="D")
sales = np.sin(np.arange(365) * 2 * np.pi / 365) * 1000 + 5000 # 계절성 패턴
sales += np.random.normal(0, 200, 365) # 노이즈 추가
# 데이터프레임 생성
df = pd.DataFrame({"date": dates, "sales": sales})
# 예측 수행 (향후 30일)
forecast_horizon = 30
predictions = model.forecast(
context=sales.tolist(),
horizon=forecast_horizon,
freq="D"
)
# 결과 출력
print(f"향후 {forecast_horizon}일 예측값:")
for i, pred in enumerate(predictions["point_forecast"][:5]):
print(f" Day {i+1}: {pred:,.0f}원")
# 신뢰 구간도 함께 제공됨
print(f"\n90% 신뢰 구간: [{predictions['lower_90'][0]:,.0f}, {predictions['upper_90'][0]:,.0f}]")
Comparison of major time series forecasting models/services (as of January 2025):
| Model/Service | Type | Features | Cost |
|---|---|---|---|
| Google TimesFM | Foundation Model | Zero-shot, 200M params | Open source, free |
| Amazon Chronos | Foundation Model | Probabilistic, T5-based | Open source, free |
| Prophet (Meta) | Statistics + ML | Automatic seasonality detection | Open source, free |
| AWS Forecast | Managed service | AutoML, integrated management | $0.06/1K forecasts |
| Azure AutoML | Managed service | Multivariate support | Compute costs only |
"To improve sales forecasting accuracy, it would be better to try a Foundation Model like TimesFM rather than plain ARIMA. It can be applied right away with zero-shot, and there are benchmark results showing an improvement of more than 20% in MASE."
"In time series forecasting, probabilistic forecasting is more important than point forecasting. For example, in inventory management, setting safety stock at the upper bound of a 95% confidence interval lets you effectively manage stockout risk."
"Unlike traditional methods that assume stationarity in time series data, Transformer-based models also handle non-stationary time series well. However, because of context length limits, long-term patterns require separate feature engineering."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
If the training data includes information from after the forecast point, the model will overfit. When splitting time series data, always preserve chronological order and use Walk-forward Validation.
Ignoring domain-specific seasonality such as year-end peaks and weekend effects significantly reduces forecasting accuracy. Use Prophet or external calendar features.
Validate forecasting performance at multiple past points through backtesting, and evaluate with various metrics such as MAPE/MASE/CRPS. In ranges with high uncertainty, it is essential to provide forecast confidence intervals as well.