This project provides a web interface for predicting customer churn using a Logistic Regression model. It is configured for deployment on Vercel.
api/index.py: The Flask backend that serves the model prediction endpoint.public/index.html: The frontend UI.train_model.py: Script to train the model and save it asmodel.pkl.model.pkl: The trained model.schema.pkl: Schema of the features used.
-
Install dependencies:
pip install -r requirements.txt
-
Train the model (if
model.pklis missing or you want to retrain):python train_model.py
-
Run the API locally:
python api/index.py
Open
http://localhost:5000in your browser.
- Push this repository to GitHub/GitLab/Bitbucket.
- Import the project in Vercel.
- Vercel will automatically detect the configuration in
vercel.jsonand deploy the Python serverless function. - Ensure
model.pklandschema.pklare included in the repository .
Endpoint: POST /api/predict
Payload example:
{
"Gender": "Male",
"Senior Citizen": "No",
"Partner": "No",
"Dependents": "No",
"Tenure Months": 12,
"Phone Service": "Yes",
"Multiple Lines": "No",
"Internet Service": "Fiber optic",
"Online Security": "No",
"Online Backup": "No",
"Device Protection": "No",
"Tech Support": "No",
"Streaming TV": "No",
"Streaming Movies": "No",
"Contract": "Month-to-month",
"Paperless Billing": "Yes",
"Payment Method": "Electronic check",
"Monthly Charges": 70.0,
"Total Charges": 840.0
}