Views
No views yet
en) for feature labels/documentation0: No Churn1: Churnjoblib:1from pathlib import Path
2import joblib
3import pandas as pd
4
5model = joblib.load(Path("churn_model_v1.pkl"))
6
7sample = pd.DataFrame(
8 [
9 {
10 "gender": "Female",
11 "SeniorCitizen": "0",
12 "Partner": "Yes",
13 "Dependents": "No",
14 "tenure": 12,
15 "PhoneService": "Yes",
16 "MultipleLines": "No",
17 "InternetService": "Fiber optic",
18 "OnlineSecurity": "No",
19 "OnlineBackup": "Yes",
20 "DeviceProtection": "No",
21 "TechSupport": "No",
22 "StreamingTV": "Yes",
23 "StreamingMovies": "Yes",
24 "Contract": "Month-to-month",
25 "PaperlessBilling": "Yes",
26 "PaymentMethod": "Electronic check",
27 "MonthlyCharges": 89.1,
28 "TotalCharges": 1069.2,
29 }
30 ]
31)
32
33prediction = model.predict(sample)[0]
34probability = model.predict_proba(sample)[0][1]
35print(prediction, probability)WA_Fn-UseC_-Telco-Customer-Churn.csv with the standard churn target column (Churn).customerIDTotalCharges to numeric and removed rows with invalid target/critical numeric valueshandle_unknown='ignore')n_splits=5)GridSearchCV with scoring = f1class_weight=balancedmax_depth=8min_samples_leaf=4min_samples_split=2n_estimators=200