Download app/main.py from KLEB38/OC_P5_v2: direct link, hf CLI and curl.
- Browser
- Download file 660 Bytes
-
https://huggingface.co/KLEB38/OC_P5_v2/resolve/main/app/main.py
- Command line
-
hf download hf://KLEB38/OC_P5_v2/app/main.py
-
curl -L -o main.py https://huggingface.co/KLEB38/OC_P5_v2/resolve/main/app/main.py
660 Bytes
| from fastapi import FastAPI | |
| import joblib | |
| app = FastAPI() # On crée l'outil (le guichet) | |
| # Au démarrage, on charge ton pipeline | |
| model = joblib.load('app/pipeline_rh.joblib') | |
| # La page d'accueil de ton API | |
| def read_root(): | |
| return {"message": "Bienvenue sur l'API RH de Futurisys"} | |
| def predict(data: dict): | |
| # 1. On transforme le dictionnaire reçu en DataFrame pandas | |
| df = pd.DataFrame([data]) | |
| # 2. On utilise le pipeline pour faire la prédiction | |
| prediction = model.predict(df) | |
| # 3. On renvoie le résultat au format JSON | |
| return { | |
| "statut_employe": int(prediction[0]) | |
| } |