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...
We'll cover the following...
Solution
Python 3.5
def churn_predict_acc(X,Y,test_inputs,test_outputs):# Fit modellr = LogisticRegression()lr.fit(X,Y)# Get predictions and accuracypreds = lr.predict(test_inputs)acc = accuracy_score(y_true = test_outputs,y_pred = preds)return accdf = 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 ...