Search⌘ K
AI Features

Solution Review: Churn Prediction

Explore how to build a logistic regression model for churn prediction by fitting data and evaluating accuracy. Understand the process of applying predictive models to solve real business problems.

We'll cover the following...

Solution

Python 3.5
def churn_predict_acc(X,Y,test_inputs,test_outputs):
# Fit model
lr = LogisticRegression()
lr.fit(X,Y)
# Get predictions and accuracy
preds = lr.predict(test_inputs)
acc = accuracy_score(y_true = test_outputs,y_pred = preds)
return acc
df = pd.read_csv('telecom_churn_.csv')
X = df.drop(columns = ['Class'])
Y = df[['Class']]
print(churn_predict_acc(X,Y,X[:100],Y[:100]))

The solution is simple. We make a logistic regression model in line 3. We fit the model ...