LoslegenKostenlos loslegen

Computing other metrics

In addition to accuracy, let's also compute the F1 score of this new model to get a better picture of model performance.

A 70-30 train-test split has already been done for you, and all necessary modules have been imported.

Diese Übung ist Teil des Kurses

Marketing Analytics: Predicting Customer Churn in Python

Kurs anzeigen

Anleitung zur Übung

  • Predict the labels of the test set.
  • Print the F1 score.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Import f1_score
from sklearn.metrics import f1_score

# Instantiate the classifier
clf = RandomForestClassifier()

# Fit to the data
clf.fit(X_train, y_train)

# Predict the labels of the test set
y_pred = ____

# Print the F1 score
print(____)
Code bearbeiten und ausführen