BaşlayınÜcretsiz Başlayın

Computing accuracy

Having split your data into training and testing sets, you can now fit your model to the training data and then predict the labels of the test data. That's what you'll practice doing in this exercise.

So far, you've used Logistic Regression and Decision Trees. Here, you'll use a RandomForestClassifier, which you can think of as an ensemble of Decision Trees that generally outperforms a single Decision Tree.

Your work in the previous exercises has carried over, and the training and test sets are available in the variables X_train, X_test, y_train, and y_test.

Bu egzersiz

Marketing Analytics: Predicting Customer Churn in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Import RandomForestClassifier from sklearn.ensemble.
  • Instantiate a RandomForestClassifier as clf.
  • Fit clf to the training data: X_train and y_train.
  • Compute the accuracy of clf on the testing data using the .score() method.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Import RandomForestClassifier


# Instantiate the classifier
clf = ____

# Fit to the training data


# Compute accuracy
print(____.____(____, ____))
Kodu Düzenle ve Çalıştır