How med00amine/customer-churn-api works
This is a customer-churn prediction API with a separate exploration and model-training workflow. A client submits customer data to FastAPI, which validates it and calls the prediction function; that function maps fields, requests a churn prediction and probability, then derives a risk level and recommendation. The README also describes a preprocessing pipeline and Random Forest model. Source sampling shows training saves a model, but the serving code assigns a path string rather than loading an estimator, so artifact-to-inference wiring is not established here.
Main entry points: main.py FastAPI app · preprocess.py Preprocessing · predict.py Prediction function · train.py Model training
Components 13
Data and training
- Data exploration
training/explore.py - Preprocessing
training/preprocess.py - Model training
training/train.py - Preprocessor artifact
models - Trained model
models
API serving
- FastAPI app
app/main.py - Request validation
app/schemas.py
Prediction logic
- Prediction function
app/predict.py - Churn and risk result
Runtime support
- API configuration
app/config.py - Logging
app/logger.py
Other components
- API client
- Telco churn data
data/Telco_customer_churn.xlsx
Connections 12
- Data exploration → Telco churn data: reads
- Preprocessing → Telco churn data: reads
- Model training → Preprocessing: imports pipeline
- Preprocessing → Preprocessor artifact: writes preprocessor
- Model training → Trained model: writes model
- API client → FastAPI app: sends request
- FastAPI app → Request validation: validates input
- FastAPI app → Prediction function: calls
- Prediction function → Churn and risk result: returns
- API configuration → FastAPI app: provides settings
- FastAPI app → Logging: logs startup
- Prediction function → Logging: logs prediction