mirzafathir/usd-idr-forecasting
<div align="center">
๐ USD/IDR Exchange Rate Forecasting
XGBoost + BiLSTM Ensemble Pipeline โ Prediksi kurs USD/IDR dengan akurasi tinggi
    
</div>
๐๏ธ Daftar Isi
- Demo
- Overview
- Arsitektur Pipeline
- Features
- Model Performance
- Cara Penggunaan
- API Endpoint
- Deployment
- Struktur Proyek
๐ฎ Demo
Live Dashboard: Jalankan aplikasi Streamlit di atas untuk melihat forecast interaktif, analisis SHAP, dan prediksi 14-hari ke depan dengan confidence interval.
๐ Overview
Proyek ini merupakan Final Project Big Data โ Semester 6, TC ITS yang membangun pipeline forecasting kurs USD/IDR secara end-to-end:
- Data: Harga harian USD/IDR + makroekonomi (BI Rate, inflasi, emas, minyak) dari 2000โ2026
- Target: Log-return USD/IDR (bukan level harga langsung) โ menghindari extrapolation cap pada tree-based model
- Forecasting: Rekursif multi-step dengan back-transform:
level[t+1] = level[t] ร exp(predicted_return) - Live Data: Harga USD/IDR real-time via Yahoo Finance (cache 5 menit)
๐๏ธ Arsitektur Pipeline
Raw Data (yfinance / CSV)
โ
โผ
โโโโโโโโโโโโโโโโโโโโ
โ Feature Eng. โ 27 fitur: lag, rolling, RSI, BI-Fed spread,
โ (src/features) โ commodity returns, kalender
โโโโโโโโโโฌโโโโโโโโโโ
โ
โโโโโโดโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโ โโโโโโโโโโโโ
โ XGBoost โ โ BiLSTM โ (opsional, butuh GPU/Linux)
โ + Q10 โ โ 2-layer โ
โ + Q90 โ โ Huber โ
โโโโโโฌโโโโโ โโโโโโฌโโโโโโ
โ โ
โโโโโโโโโโโโฌโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโ
โ Ridge โ Meta-learner ensemble
โ Ensemble โ stacking XGBoost + LSTM
โโโโโโโโฌโโโโโโโโ
โผ
Recursive Multi-Step Forecast
+ Quantile CI (Q10 / Q90)Walk-Forward Validation:
Expanding Window: Blocked (purge_gap=5):
[====Train====|Val] [=Train=|gap|=Val=|gap|...]
[======Train======|Val] [==Train==|gap|=Val=|gap|...]
[========Train========|Val] [===Train===|gap|=Val=|gap|...]๐ Features (27 Variabel)
๐ Model Performance
XGBoost (Test Set: Jan 2020 โ Jun 2026)
Walk-Forward Validation
14-Day Forecast dengan Confidence Interval
Feature Importance (SHAP-based)
๐ Cara Penggunaan
1. Clone & Install
git clone https://huggingface.co/spaces/YOUR_USERNAME/usd-idr-forecasting
cd usd-idr-forecasting
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt2. Jalankan Dashboard
streamlit run app.py
# โ http://localhost:85013. Jalankan API
uvicorn api:app --reload --port 8000
# โ Swagger: http://localhost:8000/docs4. Generate Artifacts (tanpa training ulang)
python generate_artifacts.py
# ~10 detik, menghasilkan semua CSV/PNG di output/ dan figure/5. Training Ulang (opsional)
# Fast mode (~15-20 menit)
python train_fp.py --fast
# Full GridSearchCV (~60-90 menit)
python train_fp.py๐ API Endpoint
# Health check
curl http://localhost:8000/
# 14-day forecast
curl -X POST http://localhost:8000/forecast/multistep \
-H "Content-Type: application/json" \
-d '{"n_steps": 14}'
# Metrics
curl http://localhost:8000/metricsSwagger docs: http://localhost:8000/docs
๐ณ Deployment
Docker Compose (Streamlit + FastAPI)
docker-compose up --build -d
# Dashboard โ http://localhost:8501
# API โ http://localhost:8000Streamlit Cloud / HF Spaces
Push repo ke GitHub/HF โ auto-deploy via app.py + requirements.txt.
GitHub Actions CI
# .github/workflows/ci.yml sudah tersedia:
# - Syntax check semua file Python
# - Import check (pastikan semua dep tersedia)
# - Dataset integrity check
# - Docker build๐ Struktur Proyek
.
โโโ app.py # Streamlit dashboard v3.0
โโโ api.py # FastAPI inference server v3.0
โโโ train_fp.py # Pipeline training XGBoost + BiLSTM
โโโ generate_artifacts.py # Generate semua output/ tanpa training ulang
โโโ requirements.txt
โโโ Makefile
โโโ docker-compose.yml
โโโ .streamlit/config.toml
โโโ .github/workflows/ci.yml
โ
โโโ src/
โ โโโ config.py # Konfigurasi global (dataclass)
โ โโโ features.py # Feature engineering pipeline
โ โโโ evaluation.py # Metrics + walk-forward CV
โ โโโ inference.py # Multi-step forecast functions
โ
โโโ output/ # Model artifacts + CSV results
โ โโโ xgboost_model.pkl
โ โโโ xgboost_q10.pkl # Quantile 10% (lower CI)
โ โโโ xgboost_q90.pkl # Quantile 90% (upper CI)
โ โโโ model_config.json
โ โโโ evaluation_results.csv
โ โโโ multistep_forecast_14d.csv
โ
โโโ figure/ # 16 visualisasi PNG
โโโ summary_dashboard.png
โโโ actual_vs_pred_xgboost.png
โโโ feature_importance_xgboost.png
โโโ walk_forward_validation.png
โโโ ...๐ Tech Stack
๐ค Author
Mirza Fathir R. โ Teknik Komputer, Institut Teknologi Sepuluh Nopember (ITS) Final Project Big Data, Semester 6, 2025/2026
<div align="center"> <sub>Built with โค๏ธ for Big Data Final Project โ TC ITS 2025/2026</sub> </div>
