Instructions to use amarakoon2001/telco-churn-prediction with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use amarakoon2001/telco-churn-prediction with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("amarakoon2001/telco-churn-prediction", "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
Telco Churn Prediction
A scikit-learn Logistic Regression pipeline that estimates customer churn probability from 19 customer, account, billing, and service attributes.
Created by Anjula Prasad as a machine learning portfolio project.
Model details
- Task: Binary classification β churn or stay
- Dataset: Telco Customer Churn, containing 7,043 customers
- Numeric preprocessing: StandardScaler
- Categorical preprocessing: OneHotEncoder with
drop="first"andhandle_unknown="ignore" - Classifier: Logistic Regression
- Training library: scikit-learn 1.6.1
- Demo classification threshold: 0.38
The uploaded Joblib bundle includes the fitted pipeline, classification threshold, input column names, and scikit-learn version.
Usage
Install the dependencies:
pip install scikit-learn==1.6.1 pandas numpy joblib huggingface_hub
Download the bundle and predict:
import joblib
import pandas as pd
from huggingface_hub import hf_hub_download
path = hf_hub_download(
repo_id="amarakoon2001/telco-churn-prediction",
filename="telco_churn_pipeline_bundle.joblib",
)
bundle = joblib.load(path)
pipeline = bundle["pipeline"]
threshold = float(bundle["threshold"])
customer = pd.DataFrame([{
"gender": "Female",
"SeniorCitizen": 0,
"Partner": "No",
"Dependents": "No",
"tenure": 2,
"PhoneService": "Yes",
"MultipleLines": "No",
"InternetService": "Fiber optic",
"OnlineSecurity": "No",
"OnlineBackup": "No",
"DeviceProtection": "No",
"TechSupport": "No",
"StreamingTV": "No",
"StreamingMovies": "No",
"Contract": "Month-to-month",
"PaperlessBilling": "Yes",
"PaymentMethod": "Electronic check",
"MonthlyCharges": 85.0,
"TotalCharges": 170.0,
}])
customer = customer[bundle["input_columns"]]
churn_index = list(pipeline.classes_).index(1)
probability = float(
pipeline.predict_proba(customer)[0, churn_index]
)
prediction = "Churn" if probability >= threshold else "Stay"
print(f"Churn probability: {probability:.2%}")
print(f"Classification threshold: {threshold:.2f}")
print(f"Prediction: {prediction}")
Numeric inputs must contain valid numbers. Supply categorical values using the dataset's original labels. Charges use the source dataset's monetary units, not LKR.
Apply the saved threshold to predict_proba as shown above to reproduce
the bundle's classification rule.
Only load Joblib files from sources you trust.
Evaluation
The current demo code reports the following exploratory results:
| Metric | Value |
|---|---|
| Test ROC-AUC | 0.843 |
| Test accuracy | 77.64% |
| Churn precision | 56.5% |
| Churn recall | 68.7% |
| Churn F1-score | 0.620 |
| Mean 5-fold CV ROC-AUC | 0.848 |
Precision, recall, F1, and accuracy use a threshold of 0.38.
The reported split contains 4,225 training, 1,409 validation, and 1,409 test customers. Preprocessing is fitted within each training fold. The threshold was selected using validation F1-score.
These metrics are transcribed from the demo's evaluation notes; they have not been independently reproduced for this model card.
Intended use and limitations
This model is intended for learning, experimentation, and portfolio demonstration.
The test split had already been inspected during earlier experiments. Results are therefore exploratory and do not constitute a fresh, independent final evaluation.
Probabilities have not been separately calibrated. Performance may differ for other customer populations or telecom providers.
This model has not been validated for production customer decisions.
- Downloads last month
- -