Adding all files to the project
Browse files- .github/workflows/CI_CD.yml +45 -0
- .gitignore +18 -0
- README.md +57 -0
- app/main.py +24 -0
- app/pipeline_rh.joblib +3 -0
- notebooks/Lebayle_Kevin_1_EDA_16012026.ipynb +3 -0
- notebooks/Lebayle_Kevin_2_FE et Modelisation_16012026.ipynb +3 -0
- notebooks/Lebayle_Kevin_3_pyproject_16012026.toml +20 -0
- requirements.txt +6 -0
.github/workflows/CI_CD.yml
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Python Installation Check
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches: [ main ]
|
| 6 |
+
pull_request:
|
| 7 |
+
branches: [ main ]
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
|
| 11 |
+
build:
|
| 12 |
+
runs-on: ubuntu-latest
|
| 13 |
+
steps:
|
| 14 |
+
- uses: actions/checkout@v6
|
| 15 |
+
|
| 16 |
+
- name: Set up Python
|
| 17 |
+
uses: actions/setup-python@v6
|
| 18 |
+
with:
|
| 19 |
+
python-version: '3.13.5'
|
| 20 |
+
cache: 'pip'
|
| 21 |
+
|
| 22 |
+
- name: Install dependencies
|
| 23 |
+
run: |
|
| 24 |
+
python -m pip install --upgrade pip
|
| 25 |
+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
deploy:
|
| 29 |
+
needs: build
|
| 30 |
+
runs-on: ubuntu-latest
|
| 31 |
+
steps:
|
| 32 |
+
- uses: actions/checkout@v6
|
| 33 |
+
with:
|
| 34 |
+
fetch-depth: 0
|
| 35 |
+
lfs: true
|
| 36 |
+
|
| 37 |
+
- name: Push to Hub
|
| 38 |
+
env:
|
| 39 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 40 |
+
run: git push --force https://KLEB38:$HF_TOKEN@huggingface.co/KLEB38/OC_P5 main
|
| 41 |
+
|
| 42 |
+
- name: Check large files
|
| 43 |
+
uses: ActionsDesk/lfs-warning@v2.0
|
| 44 |
+
with:
|
| 45 |
+
filesizelimit: 10485760 # 10MB
|
.gitignore
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Python bytecode (fichiers générés automatiquement)
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
|
| 5 |
+
# Environnements virtuels (trop lourds pour Git)
|
| 6 |
+
venv/
|
| 7 |
+
env/
|
| 8 |
+
.env
|
| 9 |
+
|
| 10 |
+
# Configuration VS Code
|
| 11 |
+
.vscode/
|
| 12 |
+
|
| 13 |
+
# Jupyter Notebook checkpoints
|
| 14 |
+
.ipynb_checkpoints/
|
| 15 |
+
|
| 16 |
+
# Fichiers système
|
| 17 |
+
.DS_Store
|
| 18 |
+
Thumbs.db
|
README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# HR Attrition Prediction API - Futurisys
|
| 2 |
+
|
| 3 |
+
This project provides a professional-grade REST API designed to predict employee attrition for **Futurisys**.
|
| 4 |
+
It uses a Machine Learning pipeline to analyze employee data and provide actionable insights for HR departments.
|
| 5 |
+
|
| 6 |
+
## Project Overview
|
| 7 |
+
The objective is to identify employees at risk of leaving the company by analyzing HR features.
|
| 8 |
+
|
| 9 |
+
**Key Features:**
|
| 10 |
+
- **Machine Learning Pipeline:** A robust model (Gradient Boosting/Random Forest) integrated with automated preprocessing.
|
| 11 |
+
- **FastAPI Framework:** High-performance API with built-in validation and asynchronous support.
|
| 12 |
+
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
## Project Structure
|
| 16 |
+
|
| 17 |
+
```text
|
| 18 |
+
.
|
| 19 |
+
├── app/
|
| 20 |
+
│ ├── main.py # Core API logic and Pydantic schemas
|
| 21 |
+
│ └── pipeline_rh.joblib # Serialized Scikit-Learn pipeline (Model + Scalers)
|
| 22 |
+
├── notebooks/ # Research, EDA, and model training notebooks
|
| 23 |
+
├── .gitignore # Ensures clean version control by ignoring temp files
|
| 24 |
+
├── requirements.txt # List of Python dependencies
|
| 25 |
+
└── README.md # Project documentation
|
| 26 |
+
|
| 27 |
+
```
|
| 28 |
+
## Installation & Setup
|
| 29 |
+
|
| 30 |
+
1. Prerequisites
|
| 31 |
+
|
| 32 |
+
Python 3.8+
|
| 33 |
+
Git
|
| 34 |
+
|
| 35 |
+
3. Clone the Repository
|
| 36 |
+
|
| 37 |
+
git clone <your-repository-url>
|
| 38 |
+
cd <your-project-folder>
|
| 39 |
+
|
| 40 |
+
3. Install dependencies
|
| 41 |
+
|
| 42 |
+
pip install -r requirements.txt
|
| 43 |
+
|
| 44 |
+
## Usage
|
| 45 |
+
|
| 46 |
+
### Running the API
|
| 47 |
+
|
| 48 |
+
## API Endpoints
|
| 49 |
+
|
| 50 |
+
GET /
|
| 51 |
+
|
| 52 |
+
POST /predict
|
| 53 |
+
|
| 54 |
+
## Author
|
| 55 |
+
Kevin L. - Data Science & Machine Learning Student
|
| 56 |
+
|
| 57 |
+
|
app/main.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
import joblib
|
| 3 |
+
|
| 4 |
+
app = FastAPI() # On crée l'outil (le guichet)
|
| 5 |
+
|
| 6 |
+
# Au démarrage, on charge ton pipeline
|
| 7 |
+
model = joblib.load('app/pipeline_rh.joblib')
|
| 8 |
+
|
| 9 |
+
@app.get("/") # La page d'accueil de ton API
|
| 10 |
+
def read_root():
|
| 11 |
+
return {"message": "Bienvenue sur l'API RH de Futurisys"}
|
| 12 |
+
|
| 13 |
+
@app.post("/predict")
|
| 14 |
+
def predict(data: dict):
|
| 15 |
+
# 1. On transforme le dictionnaire reçu en DataFrame pandas
|
| 16 |
+
df = pd.DataFrame([data])
|
| 17 |
+
|
| 18 |
+
# 2. On utilise le pipeline pour faire la prédiction
|
| 19 |
+
prediction = model.predict(df)
|
| 20 |
+
|
| 21 |
+
# 3. On renvoie le résultat au format JSON
|
| 22 |
+
return {
|
| 23 |
+
"statut_employe": int(prediction[0])
|
| 24 |
+
}
|
app/pipeline_rh.joblib
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d2f9f36f06fd2578a274d7661a710f7c0693dad3ecc83e2c2f80b5ad674852f9
|
| 3 |
+
size 197529
|
notebooks/Lebayle_Kevin_1_EDA_16012026.ipynb
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cb8b396c439597c3b2784b7e16a907d2c3f31f50238ec74c96a89c4895f5243a
|
| 3 |
+
size 15777318
|
notebooks/Lebayle_Kevin_2_FE et Modelisation_16012026.ipynb
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d0804493151cd1c12848cc08fcba20dc6a0c57dc8f93fae24f17414d494ff357
|
| 3 |
+
size 4669452
|
notebooks/Lebayle_Kevin_3_pyproject_16012026.toml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "p4 Kevin Lebayle"
|
| 3 |
+
version = "1.0"
|
| 4 |
+
description = "Attrition in ESN"
|
| 5 |
+
requires-python = ">=3.13"
|
| 6 |
+
|
| 7 |
+
dependencies = [
|
| 8 |
+
"pandas>=2.3.3",
|
| 9 |
+
"numpy>=2.3.5",
|
| 10 |
+
"matplotlib>=3.10.8",
|
| 11 |
+
"seaborn>=0.13.2",
|
| 12 |
+
"scikit-learn>=1.8.0",
|
| 13 |
+
"shap>=0.50.0",
|
| 14 |
+
"ipykernel>=6.31.0",
|
| 15 |
+
"skopt>=0.10.2",
|
| 16 |
+
,
|
| 17 |
+
]
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn
|
| 3 |
+
joblib
|
| 4 |
+
scikit-learn
|
| 5 |
+
pandas
|
| 6 |
+
psycopg2-binary
|