docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
---
|
||||
id: wiki-2026-0508-time-series-analysis
|
||||
title: Time Series Analysis
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [Time Series, TSA, Forecasting, Temporal Analysis]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [time-series, forecasting, ml, statistics]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: python
|
||||
framework: statsmodels-prophet-darts-nixtla
|
||||
---
|
||||
|
||||
# Time Series Analysis
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 시간 축 위의 dependency가 modeling target"**. ARIMA의 classical 1970s 시대를 거쳐, 2020s에 Transformer-based foundation models (TimeGPT, Chronos, Moirai) 가 zero-shot forecasting을 가능케 했다. 매 2026 현재 hybrid (statistical + neural) 가 production default.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 components
|
||||
- **Trend**: long-term direction.
|
||||
- **Seasonality**: periodic (daily, weekly, yearly).
|
||||
- **Cyclic**: aperiodic fluctuations.
|
||||
- **Residual**: noise / unexplained.
|
||||
|
||||
### 매 stationarity
|
||||
- Strict / weak stationarity 의 distinction.
|
||||
- ADF, KPSS test 로 확인.
|
||||
- Differencing, log transform, Box-Cox 로 stationarize.
|
||||
|
||||
### 매 model spectrum
|
||||
1. **Classical**: ARIMA, SARIMA, ETS (Exponential Smoothing), Holt-Winters.
|
||||
2. **ML**: XGBoost on lag features, LightGBM (M5 winner).
|
||||
3. **Deep**: LSTM, Temporal Fusion Transformer, N-BEATS, N-HiTS.
|
||||
4. **Foundation models** (2024+): TimeGPT, Chronos (Amazon), Moirai (Salesforce), TimesFM (Google).
|
||||
|
||||
### 매 응용
|
||||
1. Demand forecasting (retail, supply chain).
|
||||
2. Anomaly detection (monitoring, fraud).
|
||||
3. Financial markets (volatility, price).
|
||||
4. Energy load prediction.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### Pattern 1: ARIMA baseline (statsmodels)
|
||||
```python
|
||||
from statsmodels.tsa.arima.model import ARIMA
|
||||
import pandas as pd
|
||||
|
||||
ts = pd.read_csv("sales.csv", parse_dates=["date"], index_col="date")["y"]
|
||||
model = ARIMA(ts, order=(2, 1, 2), seasonal_order=(1, 1, 1, 12))
|
||||
fit = model.fit()
|
||||
forecast = fit.forecast(steps=12)
|
||||
```
|
||||
|
||||
### Pattern 2: Prophet (Meta)
|
||||
```python
|
||||
from prophet import Prophet
|
||||
|
||||
df = pd.DataFrame({"ds": dates, "y": values})
|
||||
m = Prophet(yearly_seasonality=True, weekly_seasonality=True)
|
||||
m.add_country_holidays(country_name="KR")
|
||||
m.fit(df)
|
||||
future = m.make_future_dataframe(periods=90)
|
||||
fc = m.predict(future)
|
||||
```
|
||||
|
||||
### Pattern 3: Darts (unified library, 2026 modern)
|
||||
```python
|
||||
from darts import TimeSeries
|
||||
from darts.models import TFTModel # Temporal Fusion Transformer
|
||||
|
||||
series = TimeSeries.from_dataframe(df, "ds", "y")
|
||||
train, val = series.split_before(0.8)
|
||||
|
||||
model = TFTModel(
|
||||
input_chunk_length=24,
|
||||
output_chunk_length=12,
|
||||
hidden_size=64,
|
||||
lstm_layers=2,
|
||||
num_attention_heads=4,
|
||||
)
|
||||
model.fit(train, val_series=val)
|
||||
pred = model.predict(n=12)
|
||||
```
|
||||
|
||||
### Pattern 4: Foundation model zero-shot (Chronos)
|
||||
```python
|
||||
from chronos import ChronosPipeline
|
||||
import torch
|
||||
|
||||
pipe = ChronosPipeline.from_pretrained(
|
||||
"amazon/chronos-t5-large",
|
||||
device_map="cuda",
|
||||
torch_dtype=torch.bfloat16,
|
||||
)
|
||||
context = torch.tensor(history) # no fine-tune
|
||||
forecast = pipe.predict(context, prediction_length=24, num_samples=20)
|
||||
median = forecast.median(dim=1).values
|
||||
```
|
||||
|
||||
### Pattern 5: Anomaly detection (rolling z-score)
|
||||
```python
|
||||
import numpy as np
|
||||
|
||||
def rolling_anomaly(ts, window=30, threshold=3.0):
|
||||
rolling_mean = ts.rolling(window).mean()
|
||||
rolling_std = ts.rolling(window).std()
|
||||
z = (ts - rolling_mean) / rolling_std
|
||||
return np.abs(z) > threshold
|
||||
```
|
||||
|
||||
### Pattern 6: Backtesting (walk-forward)
|
||||
```python
|
||||
from sklearn.model_selection import TimeSeriesSplit
|
||||
|
||||
tscv = TimeSeriesSplit(n_splits=5)
|
||||
scores = []
|
||||
for train_idx, test_idx in tscv.split(X):
|
||||
model.fit(X[train_idx], y[train_idx])
|
||||
pred = model.predict(X[test_idx])
|
||||
scores.append(mape(y[test_idx], pred))
|
||||
```
|
||||
|
||||
### Pattern 7: Nixtla statsforecast (fast classical)
|
||||
```python
|
||||
from statsforecast import StatsForecast
|
||||
from statsforecast.models import AutoARIMA, AutoETS
|
||||
|
||||
sf = StatsForecast(
|
||||
models=[AutoARIMA(season_length=12), AutoETS(season_length=12)],
|
||||
freq="M",
|
||||
n_jobs=-1,
|
||||
)
|
||||
sf.fit(df)
|
||||
forecast = sf.forecast(h=12, level=[80, 95])
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| <1000 points, single series | ARIMA / Prophet |
|
||||
| Many related series, hierarchical | Nixtla statsforecast (parallel) |
|
||||
| Multivariate, many covariates | TFT, N-BEATSx (Darts) |
|
||||
| Zero-shot, no training data | Chronos / TimeGPT / TimesFM |
|
||||
| Real-time anomaly | Rolling z-score / Isolation Forest |
|
||||
|
||||
**기본값**: Prophet for prototype, Darts TFT or Chronos zero-shot for production.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Machine Learning]] · [[Statistics]]
|
||||
- 변형: [[ARIMA]] · [[Prophet]]
|
||||
- 응용: [[Anomaly Detection]]
|
||||
- Adjacent: [[데이터 사이언스 및 ML 엔지니어링|LSTM]] · [[Transformer]] · [[Foundation Models]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: temporal data forecasting, anomaly detection, capacity planning.
|
||||
**언제 X**: cross-sectional data without time component, pure classification.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **No stationarity check**: ARIMA에 non-stationary series 직접 적용.
|
||||
- **Random shuffling**: time series 의 train/test split 에 random shuffle 사용 (data leakage).
|
||||
- **MAPE on near-zero values**: division-by-zero / explosion. SMAPE 또는 MASE 사용.
|
||||
- **Ignoring seasonality**: yearly/weekly cycle 의 무시.
|
||||
- **Look-ahead bias**: future information 의 feature engineering 에 사용.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Hyndman, "Forecasting: Principles and Practice" 3rd ed; M-competition results; Chronos paper 2024).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — full TSA spectrum (classical → foundation models) with code |
|
||||
Reference in New Issue
Block a user