A production-ready machine learning pipeline for regression, built around the Moroccan job market. Follows a 10-step professional ML blueprint from data ingestion to a live FastAPI deployment stub.
# 🇲🇦 Morocco Job Market — Salary Prediction
A production-ready machine learning pipeline for regression, built around the Moroccan job market. Follows a 10-step professional ML blueprint from data ingestion to a live FastAPI deployment stub.
---
## 📋 Pipeline Overview
| Step | Stage | Description |
|------|-------|-------------|
| 1 | Environment & Ingestion | Load/generate data, configure libraries |
| 2 | Exploratory Data Analysis | Distributions, salary by city/sector, correlations |
| 3 | Preprocessing | Imputation, scaling & encoding inside a `ColumnTransformer` |
| 4 | Feature Engineering | Seniority bands, major-city flag, language×management interaction |
| 5 | Validation Boundary | Train/test split before any fitting |
| 6 | Modeling | Ridge, Random Forest, Gradient Boosting |
| 7 | Evaluation Scorecard | RMSE, MAE, R² with visual diagnostics |
| 8 | Hyperparameter Optimization | `RandomizedSearchCV` |
| 9 | Model Serialization | Joblib artifact with bundled preprocessor |
| 10 | Production Deployment | FastAPI `/predict` and `/health` endpoints |
---
## 🚀 Quickstart
### 1. Clone the repository
```bash
git clone
github.com /morocco-salary-prediction.git
cd morocco-salary-prediction
```
### 2. Create a virtual environment
```bash
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
```
### 3. Install dependencies
```bash
pip install -r requirements.txt
```
### 4. Run the notebook
```bash
jupyter lab morocco_salary_prediction.ipynb
```
### 5. (Optional) Run the production API
After executing the notebook (which writes the `.pkl` artifact and generates `app.py`):
```bash
pip install fastapi uvicorn
uvicorn app:app --reload
```
API endpoints:
- `POST /predict` — returns `{ "predicted_monthly_salary_mad": float, "currency": "MAD" }`
- `GET /health` — returns `{ "status": "ok", "model_r2": float }`
Example request body for `/predict`:
```json
{
"years_experience": 5,
"education_level": "Master (Bac+5)",
"city" …