0
0
Digital Marketingknowledge~10 mins

Churn prediction and prevention in Digital Marketing - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the library used for building a logistic regression model for churn prediction.

Digital Marketing
from sklearn.linear_model import [1]
Drag options to blanks, or click blank then click option'
ALogisticRegression
BDecisionTreeClassifier
CRandomForestClassifier
DKNeighborsClassifier
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a tree-based model instead of logistic regression for this import.
Confusing the import path for logistic regression.
2fill in blank
medium

Complete the code to split the dataset into training and testing sets for churn prediction.

Digital Marketing
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=[1], random_state=42)
Drag options to blanks, or click blank then click option'
A0.1
B0.7
C0.5
D0.3
Attempts:
3 left
💡 Hint
Common Mistakes
Using too large a test size, which reduces training data.
Using too small a test size, which may not represent the data well.
3fill in blank
hard

Fix the error in the code to train the logistic regression model for churn prediction.

Digital Marketing
model = LogisticRegression()
model.[1](X_train, y_train)
Drag options to blanks, or click blank then click option'
Apredict
Btransform
Cfit
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Using predict instead of fit to train the model.
Using transform which is for data preprocessing.
4fill in blank
hard

Fill both blanks to calculate accuracy and print the result for the churn prediction model.

Digital Marketing
accuracy = [1](y_test, y_pred)
print('Accuracy:', [2])
Drag options to blanks, or click blank then click option'
Aaccuracy_score
Baccuracy
Cy_pred
Attempts:
3 left
💡 Hint
Common Mistakes
Printing the function name instead of the accuracy variable.
Using a variable name that was not defined.
5fill in blank
hard

Fill all three blanks to create a dictionary of feature importances for churn prediction and filter features with importance greater than 0.1.

Digital Marketing
feature_importances = {feature: coef for feature, coef in zip(X.columns, model.[1][0])}
important_features = {k: v for k, v in feature_importances.items() if v [2] [3]
Drag options to blanks, or click blank then click option'
Acoef_
B>
C0.1
Dintercept_
Attempts:
3 left
💡 Hint
Common Mistakes
Using intercept_ instead of coef_ for feature importance.
Using wrong comparison operators or threshold values.