2
$\begingroup$

I am looking to work out that if I have a dataset with 100,000 existing customers who didn't churn and 20,000 previous customers that churned in the past and the business objective is to target the 20% of customers most likely to churn within the business, how would that be done?

For example, we would have to take this dataset and split it into a training and test set. Let's say the split is an 80/20 ratio for the training and test set respectively. That means that when we build our model on 80% of the data, we can no longer use this data to see if any of the existing customers are likely to churn as we cannot evaluate a model on the data we have used to train it as it. We can only use the remaining 20% of the test set in order to evaluate our model and which customers are more likely to churn or not by considering the probabilities of each customer within the test set. What if there are existing customers who have a high chance of churning that we miss because they were in the training set?

Is what I have said above correct? It's very different from predicting, for example, if someone will default on their loan as you can train on all past data and then use this data to predict on new customers coming into the bank, etc but with churn, you want to predict on the customers who exist in the bank at the moment to avoid them leaving.

Any answers are greatly appreciated.

$\endgroup$
1

2 Answers 2

1
$\begingroup$

use logistic regression to predict the probability of churn. then use the proba element of the classifier to find the top 20 highest probabilities for churn. The probabilities are used to plot true positive and true negative areas under the curve.

ytrain_pred_probas = lr.predict_proba(X_train)[:, 1]   # prob of predict as 1
fpr, tpr, thresholds = roc_curve(y_train, ytrain_pred_probas)   # precision_recall_curve
roc = pd.DataFrame({'FPR':fpr,'TPR':tpr,'Thresholds':thresholds})

_ = plt.figure()
plt.plot(roc.FPR, roc.TPR)
plt.axvline(0.1, color = '#00C851', linestyle = '--')
plt.xlabel("FPR")
plt.ylabel("TPR")

# Print the models coefficients
print(lr.coef_)

[[-2.27622202e-09  1.28517496e-09 -2.17211991e-05]]


int_coef_sum = -3.3e-10+
(1.29e-09 * feature1) + (-2.28e-09 * feature2) + (-2.17e-05 * feature3)

prob_churn =1/(1+ np.exp(-int_coef_sum))
prob_nonchurn=1-(1/(1+ np.exp(-int_coef_sum)))

cycle through each of the features for each person and calculate the probability of churn

preds_probability = clf_logistic.predict_proba(X_test)

# Create dataframes of first five predictions, and first five true labels
preds_df = pd.DataFrame(preds_probability[:,1], columns = ['prob_default'])
$\endgroup$
1
  • $\begingroup$ you can use a lift alogrithm to calculate profit based on probability for a campaign to reduce churn $\endgroup$ Aug 15, 2022 at 14:58
0
$\begingroup$

If you use k-fold cross validation, then every customer in your dataset will lie in the test set of one of the k folds. That might help alleviate the issue at hand. Finally you can train your model against your entire train set and run inferences against net new customers.

$\endgroup$
3
  • $\begingroup$ Hi, thanks so much for answering the question. I appreciate it. That makes sense but what if I want to look at churn of existing customers as opposed to new customers? My problem is that you have to train data in order to build the model but we want to apply the model to existing customers. However a certain number of customers have to be used in the training set and therefore cannot be used in the prediction because the model would simply remember these customers. $\endgroup$
    – Dean F
    May 21, 2021 at 14:08
  • $\begingroup$ cross validation does not show the top 20%. I think you use logistic regression and then look at the probability and sort the top 20% of the highest probabilities for churn $\endgroup$ Aug 9, 2022 at 14:28
  • $\begingroup$ can you provide a link to sample data and I will apply my algorithms below to find the top 20 most probable churn customers $\endgroup$ Aug 15, 2022 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.