Instructions to use asimtaseer/customer-churn-pipeline with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use asimtaseer/customer-churn-pipeline with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("asimtaseer/customer-churn-pipeline", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
๐ Customer Churn Pipeline
Predict whether a customer will churn โ before it's too late.
customer_churn_pipeline is a machine learning model built to predict customer churn in subscription-based or service businesses. It uses a complete scikit-learn Pipeline that handles preprocessing and classification in a single, production-ready object โ making it easy to integrate directly into any Python application.
๐ Introduction
Customer churn is one of the biggest challenges companies face today. Losing a customer costs far more than retaining one. This model was built to solve that problem โ giving businesses the ability to identify at-risk customers before they leave, so proactive action can be taken.
The model is packaged as a .pkl pipeline file, meaning the entire preprocessing and prediction workflow is bundled together. No separate transformation steps needed โ just load and predict.
โ๏ธ Functionality
The pipeline performs the following steps end-to-end:
| Step | Description |
|---|---|
| Preprocessing | Handles missing values, scales numerical features, and encodes categorical variables |
| Feature Engineering | Prepares structured tabular customer data for model input |
| Classification | Predicts churn probability and binary outcome (Churn / No Churn) |
| Output | Returns a prediction label: 1 (Churn) or 0 (No Churn) |
Typical input features include:
- Customer tenure (how long they've been a customer)
- Monthly charges / total charges
- Contract type (month-to-month, one year, two year)
- Internet service type
- Payment method
- Support ticket counts, etc.
๐ How to Use
1. Install Dependencies
pip install scikit-learn pandas joblib
2. Download the Model
Download customer_churn_pipeline.pkl from this repository.
3. Load and Predict
import joblib
import pandas as pd
# Load the pipeline
pipeline = joblib.load("customer_churn_pipeline.pkl")
# Sample customer data (adjust columns to match your dataset)
sample = pd.DataFrame([{
"tenure": 12,
"MonthlyCharges": 65.5,
"TotalCharges": 786.0,
"Contract": "Month-to-month",
"PaymentMethod": "Electronic check",
"InternetService": "Fiber optic",
"TechSupport": "No",
"OnlineSecurity": "No"
}])
# Predict
prediction = pipeline.predict(sample)
print("Churn Prediction:", "Yes" if prediction[0] == 1 else "No")
4. Predict Probability (optional)
proba = pipeline.predict_proba(sample)
print(f"Churn Probability: {proba[0][1] * 100:.2f}%")
โ Benefits
- ๐ Plug-and-Play โ The entire preprocessing + prediction pipeline is in one
.pklfile. No need to build separate transformers. - โก Fast Integration โ Load and use in just 3 lines of code โ ideal for production APIs or dashboards.
- ๐ Interpretable Output โ Binary output (0/1) with optional probability scores for nuanced decision-making.
- ๐งฉ Framework Agnostic โ Works with any Python backend: Flask, FastAPI, Streamlit, Django, etc.
- ๐ผ Business Ready โ Designed with real-world churn use cases in mind, enabling marketing and CRM teams to act on predictions immediately.
- ๐ก๏ธ Reliable โ Built with scikit-learn best practices and reproducible results via a serialized pipeline object.
๐ Repository Contents
| File | Description |
|---|---|
customer_churn_pipeline.pkl |
The trained and serialized ML pipeline |
README.md |
Documentation and usage guide |
๐ค Author
Asim Taseer ๐ Website: asimtaseer.unaux.com
๐ License
This project is licensed under the MIT License โ feel free to use, modify, and distribute with attribution.
- Downloads last month
- -