OC_P8_test / README.md
GitHub Actions
Sync to HF Spaces [no-ci]
42a08fb

A newer version of the Gradio SDK is available: 6.8.0

Upgrade
metadata
title: Credit Scoring - Home Credit Default Risk
emoji: πŸ“Š
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 4.44.1
python_version: '3.12'
app_file: app.py
pinned: false

OC_P6 - API Scoring Credit (MLOps)

πŸš€ Demo live

https://huggingface.co/spaces/ASI-Engineer/OC_P8_prod https://huggingface.co/spaces/ASI-Engineer/OC_P8_test

Resultats optimisation etape 4

Architecture finale

  • FastAPI/Gradio + Docker (entrypoint : app.py)
  • Monitoring logs + Evidently (drift)
  • Optimisation : VectorizedPreprocessor (15.7x)

Etapes realisees

  • Etape 2 : API + Docker + CI/CD
  • Etape 3 : Stockage + analyse prod
  • Etape 4 : Optimisation perfs (terminee)

Apercu du projet (audit rapide)

Structure du projet

OC_P6/
β”œβ”€β”€ app.py
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ pyproject.toml
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ requirements-inference.txt
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ raw/
β”‚   └── processed/
β”œβ”€β”€ logs/
β”‚   └── predictions.jsonl
β”œβ”€β”€ mlruns/
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ export_model.py
β”‚   β”œβ”€β”€ export_preprocessor.py
β”‚   β”œβ”€β”€ lightgbm.txt
β”‚   └── preprocessor.joblib
β”œβ”€β”€ notebooks/
β”‚   β”œβ”€β”€ 01_exploration.ipynb
β”‚   β”œβ”€β”€ 02_preparation_features.ipynb
β”‚   β”œβ”€β”€ 03_LGBM.ipynb
β”‚   β”œβ”€β”€ 04_regression.ipynb
β”‚   β”œβ”€β”€ 05_model_interpretation.ipynb
β”‚   β”œβ”€β”€ 06_analyse_logs.ipynb
β”‚   β”œβ”€β”€ 07_detect_data_drift.ipynb
β”‚   β”œβ”€β”€ 08_analyze_logs_2.ipynb
β”‚   β”œβ”€β”€ 09_profiling.ipynb
β”‚   └── 10_optimisation.ipynb
β”œβ”€β”€ reference/
β”‚   β”œβ”€β”€ reference.csv
β”‚   └── simulate_production_calls.py
β”œβ”€β”€ reports/
β”‚   β”œβ”€β”€ data_drift_report.html
β”‚   β”œβ”€β”€ monitoring_study.md
β”‚   └── plots/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ load_data.py
β”‚   β”œβ”€β”€ mlflow_config.py
β”‚   └── preprocessing.py
└── tests/
  β”œβ”€β”€ conftest.py
  β”œβ”€β”€ test_predict.py
  └── test_preprocessing.py

Installation (UV recommande)

curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync

Donnees

Source : Kaggle Home Credit Default Risk. Placer les fichiers dans data/raw :

  • application_train.csv
  • application_test.csv
  • bureau.csv
  • bureau_balance.csv
  • credit_card_balance.csv
  • installments_payments.csv
  • POS_CASH_balance.csv
  • previous_application.csv

Notebooks (resume)

Comment tester localement

uv sync
uv run python app.py

Option Docker :

docker build -t oc_p6:latest .
docker run --rm -it -p 7860:7860 oc_p6:latest

Usage API (local ou HF Space)

Exemple JSON minimal :

{"SK_ID_CURR": 100001, "AMT_INCOME_TOTAL": 202500.0, "AMT_CREDIT": 80000.0, "CODE_GENDER": "M", "DAYS_BIRTH": -12000}

Requete vers la Space de production :

curl -s -X POST "https://huggingface.co/spaces/ASI-Engineer/OC_P8_prod/api/predict" \
  -H "Content-Type: application/json" \
  -d '{"data":["{\"SK_ID_CURR\":100001,\"AMT_INCOME_TOTAL\":202500.0,\"AMT_CREDIT\":80000.0,\"CODE_GENDER\":\"M\",\"DAYS_BIRTH\":-12000}"]}'

Monitoring et data drift

Tests

uv run pytest

Date : 25 fevrier 2026
Statut : Projet termine OK, pret pour soutenance