Predicting New Customers
🔮 Predicting New Customer Churn
Once the model is trained, you can use it to predict the churn risk for new or existing customers. This allows you to identify high-risk accounts and intervene before they cancel their service.
Input Features
To generate a prediction, you must provide a customer profile containing the following features:
| Feature | Description | Example Value |
| :--- | :--- | :--- |
| Contract | Length of the service agreement | 'Monthly', 'One Year', 'Two Year' |
| SupportCalls | Number of interactions with customer support | 4 |
| MonthlyBill | Current monthly billing amount (INR) | 110.0 |
| PaymentMethod | Method of payment | 'CreditCard', 'BankTransfer', 'MailedCheck' |
| BillingIssues | Binary flag for historical billing disputes | 0 (No) or 1 (Yes) |
| DataUsageGB | Monthly data consumption in Gigabytes | 85.0 |
| TenureMonths | Number of months the customer has stayed | 12 |
| AutoPay | Whether the customer uses automated payments | 1 (Yes) or 0 (No) |
Usage Example
The model expects categorical variables to be transformed using the LabelEncoder instances stored during training. Use the following pattern to pass new data to the model:
import pandas as pd
# 1. Define the customer profile (Raw Data)
raw_data = {
'Contract': 'Monthly',
'SupportCalls': 5,
'MonthlyBill': 125.0,
'PaymentMethod': 'CreditCard',
'BillingIssues': 1,
'DataUsageGB': 150.0,
'TenureMonths': 3,
'AutoPay': 0
}
# 2. Transform categorical data using the le_dict encoders
new_customer = pd.DataFrame({
'Contract': [le_dict['Contract'].transform([raw_data['Contract']])[0]],
'SupportCalls': [raw_data['SupportCalls']],
'MonthlyBill': [raw_data['MonthlyBill']],
'PaymentMethod': [le_dict['PaymentMethod'].transform([raw_data['PaymentMethod']])[0]],
'BillingIssues': [raw_data['BillingIssues']],
'DataUsageGB': [raw_data['DataUsageGB']],
'TenureMonths': [raw_data['TenureMonths']],
'AutoPay': [le_dict['AutoPay'].transform([raw_data['AutoPay']])[0]]
})
# 3. Generate Prediction
prediction = model.predict(new_customer)
result = le_dict['Churn'].inverse_transform(prediction)[0]
print(f"Prediction Result: {result}")
Interpreting the Output
- Predicted Churn: Yes: The customer exhibits behavior highly correlated with churn (e.g., high support calls, monthly contract). Immediate retention efforts are recommended.
- Predicted Churn: No: The customer is likely to stay. Continue standard engagement.
Note: For bulk predictions, you can pass a DataFrame with multiple rows to
model.predict()to receive an array of churn statuses for an entire customer segment.