πŸš€ Market Regime Classifier - XGBoost Model

This is a production-ready XGBoost model for predicting market regimes (RISK_ON/RISK_OFF) in Indian financial markets (NIFTY 50). Part of a complete MLOps pipeline with experiment tracking, data versioning, and automated deployment.

🎯 Model Description

Task: Binary Classification
Algorithm: XGBoost (Extreme Gradient Boosting)
Target: Market Regime Prediction (RISK_ON vs RISK_OFF)
Framework: MLflow for experiment tracking and model registry

What are Market Regimes?

  • 🟒 RISK_ON: Favorable market conditions - lower volatility, bullish momentum, suitable for aggressive trading
  • πŸ”΄ RISK_OFF: Cautious conditions - higher volatility, defensive positioning advised

πŸ“Š Model Performance

ML Metrics

Finance Metrics (Backtesting)

Production Thresholds

  • βœ… F1 Score β‰₯ 0.65
  • βœ… Sharpe Ratio β‰₯ 0.5

πŸ”§ Features Used

The model uses four key technical indicators:

  1. India VIX - Volatility index (market fear/greed indicator)
  2. RSI (14-day) - Relative Strength Index (momentum)
  3. 50-Day MA - Short-term moving average (trend)
  4. 200-Day MA - Long-term moving average (trend)

πŸ’» Usage

Using with MLflow

import mlflow
import pandas as pd

# Load the model
model_uri = "models:/market_regime_classifier/Production"
model = mlflow.xgboost.load_model(model_uri)

# Prepare features
features = pd.DataFrame([{
    'india_vix': 15.5,
    'rsi_14': 55.3,
    'ma_50': 18500.25,
    'ma_200': 18200.75
}])

# Predict
prediction = model.predict(features)[0]
proba = model.predict_proba(features)[0]

regime = "RISK_ON" if prediction == 1 else "RISK_OFF"
confidence = proba[prediction]

print(f"Regime: {regime} (confidence: {confidence:.2%})")

Using via REST API

The model is deployed on Hugging Face Spaces with a FastAPI endpoint:

curl -X POST "https://AAdevloper-mlops-finance-pipeline.hf.space/predict_regime" \
  -H "Content-Type: application/json" \
  -d '{
    "india_vix": 15.5,
    "rsi_14": 55.3,
    "ma_50": 18500.25,
    "ma_200": 18200.75
  }'

πŸ—οΈ MLOps Pipeline

This model is part of a complete MLOps system:

Components

  • βœ… MLflow: Experiment tracking and model registry
  • βœ… DVC: Data version control
  • βœ… GitHub Actions: Automated CI/CD pipeline
  • βœ… FastAPI: REST API for model serving
  • βœ… Docker: Containerized deployment
  • βœ… Hugging Face Spaces: Cloud deployment

Training Pipeline

  1. Data preprocessing and feature engineering
  2. Train/test split with stratification
  3. XGBoost training with hyperparameters
  4. Model evaluation (ML + Finance metrics)
  5. Backtesting on historical data
  6. Model registration in MLflow
  7. Promotion to production if thresholds met

Automated Retraining

  • Scheduled weekly retraining (GitHub Actions)
  • Automatic model promotion based on performance
  • Version control for models and data

πŸ“ˆ Training Configuration

model:
  type: xgboost
  params:
    max_depth: 6
    learning_rate: 0.1
    n_estimators: 100
    objective: binary:logistic
    eval_metric: logloss

πŸ“Š Dataset

  • Source: Synthetic market data for NIFTY 50
  • Features: India VIX, RSI-14, MA-50, MA-200
  • Target: Market regime (binary classification)
  • Split: 80/20 train/test

πŸŽ“ Skills Demonstrated

  • MLOps pipeline architecture
  • Experiment tracking (MLflow)
  • Model registry management
  • Data versioning (DVC)
  • CI/CD automation (GitHub Actions)
  • Model serving (FastAPI)
  • Financial metrics & backtesting
  • Docker containerization
  • Cloud deployment (Hugging Face)

πŸ“š Project Links

πŸ”„ Model Versioning

This model is version-controlled using MLflow Model Registry:

  • Model Name: market_regime_classifier
  • Version: 1
  • Stage: Production
  • Run ID: 43544e1ed8eb4c2a9268948b6795bdf5

🀝 Contributing

This is a portfolio project demonstrating MLOps best practices. Feel free to:

  • Fork and experiment
  • Submit issues or suggestions
  • Use as reference for your own MLOps projects

πŸ“„ License

MIT License - free to use for learning and projects


Built with ❀️ to showcase MLOps skills in Finance

For questions or collaboration, visit the GitHub repository

Downloads last month
2
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support