...

/

Solution Review: Churn Prediction

Solution Review: Churn Prediction

This lesson will present the solution to the exercise of churn prediction in the previous lesson.

We'll cover the following...

Solution

Press + to interact
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 ...