charlieviettq/awesome-agent-skill / .claude/skills/algo-forecast-exponential
"algo-forecast-exponential"
Verified"Apply exponential smoothing methods for time series forecasting with weighted moving averages. Use this skill when the user needs simple, robust forecasts, implement Holt-Winters for seasonal data, or build lightweight forecasting without complex models — even if they say 'simple forecast', 'moving average prediction', or 'smoothing method'.".
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.2 KB |
| examples/sample_scenario.md | markdown | 4.8 KB |
| references/damped-trend.md | markdown | 7.5 KB |
| references/ets-framework.md | markdown | 9.6 KB |
examples/sample_scenario.md
View on GitHub# Example: 台灣連鎖藥妝品牌月銷售量預測
## Scenario
**公司:** MedBeauty 美醫美妝(台灣本土連鎖,38 間門市)
**問題:** 供應鏈主管 Jessica 需要在每月 15 日前提交下兩個月的備貨需求給主要供應商。她有 2021–2025 三月的月銷售量歷史資料(51 個月),觀察到:
- 整體銷售呈溫和上升趨勢(每月約 +1.5%)
- 明顯年度季節性:農曆新年前(1–2 月)和雙 11(11 月)有銷售高峰,7–8 月有低谷
- 無外部促銷事件變數可用
她問:「我想預測 2025 年 4 月和 5 月的銷售量,用簡單的平滑法就好,不想搞 ML 模型。」
**資料摘要(最近 12 個月,單位:千件):**
| 月份 | 銷售量 |
|------|--------|
| 2024-04 | 142 |
| 2024-05 | 138 |
| 2024-06 | 133 |
| 2024-07 | 121 |
| 2024-08 | 118 |
| 2024-09 | 134 |
| 2024-10 | 148 |
| 2024-11 | 187 |
| 2024-12 | 161 |
| 2025-01 | 195 |
| 2025-02 | 178 |
| 2025-03 | 152 |
---
## Analysis
### Phase 1: Input Validation — 確認組成結構
**Level?** 是。基礎銷售穩定存在。
**Trend?** 是,向上溫和線性趨勢。
**Seasonality?** 是,週期 s = 12,呈**加法型**(高峰振幅約 ±40K,不隨水準成比例放大)。
**結論:使用 Holt-Winters Additive(HWA)**,三個平滑參數 α、β、γ。
加法 vs. 乘法檢驗:檢視 11 月高峰相對基準的絕對差距:
- 2022-11:+39K;2023-11:+41K;2024-11:+39K → 振幅不隨水準放大 → 加法正確。
**Gate ✓** 組成確認,季節週期 = 12。
---
### Phase 2: 初始化與參數估計
**初始值(以前 12 個月,2021-04 至 2022-03 為第一個完整季節):**
```
ℓ₀ = mean(season 1) = 118.5 (千件)
b₀ = (mean(season 2) - mean(season 1)) / 12 = (129.3 - 118.5) / 12 ≈ 0.90 (千件/月)
s₀[m] = mean_m(season 1) - ℓ₀ (各月季節指數)
```
代表性季節指數(訓練資料估計):
| 月 | sₘ (千件) |
|----|-----------|
| 1月 | +38.2 |
| 2月 | +21.4 |
| 3月 | +4.1 |
| 4月 | -5.8 |
| 5月 | -9.3 |
| 6月 | -14.2 |
| 7月 | -26.7 |
| 8月 | -28.9 |
| 9月 | -12.4 |
| 10月 | +5.3 |
| 11月 | +41.1 |
| 12月 | +14.6 |
**參數最優化(最小化 in-sample MSE,網格搜尋):**
```
α = 0.28 (水準平滑:反應適中,不過度追隨單月雜訊)
β = 0.07 (趨勢平滑:趨勢變化緩慢,使用低 β)
γ = 0.12 (季節平滑:季節型態相對穩定)
```
> **IRON LAW 應用:** β = 0.07 反映趨勢確實存在但極緩慢。若手動設 β = 0.5,趨勢會在任一異常月後劇烈擺動,導致 5 月預測偏差超過 20%。
---
### Phase 3: 遞推更新至 2025-03
以 2025-03(t = 51)為預測起點,最終狀態:
```
ℓ₅₁ = 152.4 (千件)
b₅₁ = 1.12 (千件/月)
s₅₁₋₁₁ = s[4月] = -5.6 → 用於 h=1(2025-04)
s₅₁₋₁₀ = s[5月] = -9.1 → 用於 h=2(2025-05)
```
---
### Phase 4: 計算預測值
**Holt-Winters Additive 預測公式:**
```
ŷₜ₊ₕ = ℓₜ + h × bₜ + sₜ₊ₕ₋ₛ
```
**2025-04(h = 1):**
```
ŷ = 152.4 + 1 × 1.12 + (-5.6) = 147.9 ≈ 148 千件
```
**2025-05(h = 2):**
```
ŷ = 152.4 + 2 × 1.12 + (-9.1) = 145.5 ≈ 146 千件
```
---
### Phase 3: Verification — 驗證
**In-sample RMSE(51 個月):** 8.3 千件(誤差率 ≈ 5.7%)
**與基準比較:**
| 方法 | RMSE |
|------|------|
| Seasonal Naive(去年同期) | 14.2 千件 |
| Last Value Naive | 21.7 千件 |
| **Holt-Winters Additive** | **8.3 千件** |
**殘差檢查:**
- Ljung-Box Q 統計量 p = 0.21(無自相關殘差,Pass)
- 殘差標準差:8.1 千件,無系統性偏誤
**Gate ✓** 優於 Seasonal Naive,殘差無系統型態。
---
## Result
```json
{
"forecasts": [
{
"period": "2025-04",
"forecast": 148,
"level": 153.5,
"trend": 1.1,
"seasonal": -5.6
},
{
"period": "2025-05",
"forecast": 146,
"level": 153.5,
"trend": 1.1,
"seasonal": -9.1
}
],
"parameters": {
"alpha": 0.28,
"beta": 0.07,
"gamma": 0.12
},
"metadata": {
"method": "holt_winters_additive",
"seasonal_period": 12,
"rmse": 8.3,
"training_periods": 51,
"baseline_rmse_seasonal_naive": 14.2
}
}
```
**給 Jessica 的備貨建議:**
- **2025-04 預測:148 千件**(±17K,±1 RMSE 區間)
- **2025-05 預測:146 千件**(±17K)
- 4–5 月傳統為淡季,低於 3 月的 152K 屬於正常季節性回落
- 若供應商需要安全庫存,建議以 RMSE ≈ 8K 乘以 1.5 為緩衝(+12K)
**注意事項:**
- 本模型不含促銷事件變數——若 5 月有母親節特檔活動,實際銷售可能高於預測 10–20%
- 若序列長度後續低於 24 個月(如新品類),應改用 Holt(去除季節項)或 SES
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |