A production-ready Machine Learning microservice for dynamic insurance pricing and fraud detection in gig economy platforms.
GigShield ML Service powers intelligent decision-making for:
- 💰 Dynamic Premium Pricing (fair, risk-based insurance)
- 🚨 Fraud Detection (real-time anomaly detection)
Built using FastAPI, this service exposes scalable APIs that integrate seamlessly with backend systems and frontend dashboards.
- Model: XGBoost Regressor
- Objective: Predict weekly insurance premium based on worker risk
claim_count_30dtenure_daysavg_hourly_ratezone_flood_risk_scorezone_disruption_rate_90dweather_forecast_7d_risk_scoreelevation_mseasonal_factorzone_worker_density
- Isolation Forest → behavioral anomaly detection
- Autoencoder (PyTorch) → reconstruction error (deep anomaly signal)
gps_divergence_mplatform_gps_divergence_metresping_interval_variancebattery_discharge_ratedevice_account_countenrollment_delta_days
GET /health
{
"status": "ok"
}POST /predict/premium
{
"claim_count_30d": 2,
"tenure_days": 120,
"avg_hourly_rate": 90,
"zone_flood_risk_score": 0.7,
"zone_disruption_rate_90d": 0.5,
"weather_forecast_7d_risk_score": 0.6,
"elevation_m": 15,
"seasonal_factor": 1.2,
"zone_worker_density": 0.8
}{
"predicted_premium": 45.23,
"confidence_note": "Model trained with monotonic constraints",
"model_version": "v1.0"
}POST /predict/fraud
{
"gps_divergence_m": 2.5,
"platform_gps_divergence_metres": 1.8,
"ping_interval_variance": 300,
"battery_discharge_rate": 0.2,
"device_account_count": 1,
"enrollment_delta_days": 120
}{
"fraud_score": -0.02,
"is_anomaly": false,
"reconstruction_error": 0.003,
"risk_level": "low",
"model_type": "hybrid_iforest_ae",
"model_version": "v1.0"
}Frontend (Streamlit)
↓
Backend API (Node/Python)
↓
ML Service (FastAPI)
↓
ML Models (XGBoost + Isolation Forest + Autoencoder)
- FastAPI – API framework
- Scikit-learn – Isolation Forest, preprocessing
- XGBoost – Premium prediction
- PyTorch – Autoencoder
- NumPy – Numerical processing
- Joblib – Model serialization
git clone <your-repo-url>
cd GigShield-MLpython -m venv venv
venv\Scripts\activate # Windowspip install -r requirements.txtpython -m uvicorn main:app --reload- Swagger UI:
http://127.0.0.1:8000/docs
- ReDoc:
http://127.0.0.1:8000/redoc
Use Swagger UI to:
- Send requests
- Validate responses
- Simulate backend calls
- ⚡ Real-time ML inference (<100ms)
- 📈 Feature-aligned with training pipeline
- 🔍 Hybrid fraud detection (IF + AE)
- 🧩 Modular microservice architecture
- 🚀 Deployment-ready
✅ Models trained and validated ✅ API fully functional ✅ Endpoints tested 🚀 Ready for deployment
- Batch prediction endpoints
- Model monitoring & logging
- Drift detection
- Feature store integration
- CI/CD pipeline
Built as part of Guidewire Hackathon Project – GigShield
Give it a ⭐ on GitHub!