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

Confusion matrices, again

Creating a confusion matrix in Python is simple. The biggest challenge will be making sure you understand the orientation of the matrix. This exercise makes sure you understand the sklearn implementation of confusion matrices. Here, you have created a random forest model using the tic_tac_toe dataset rfc to predict outcomes of 0 (loss) or 1 (a win) for Player One.

Note: If you read about confusion matrices on another website or for another programming language, the values might be reversed.

Bu egzersiz

Model Validation in Python

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

Egzersiz talimatları

  • Import sklearn's function for creating confusion matrices.
  • Using the model rfc, create category predictions on the test set X_test.
  • Create a confusion matrix using sklearn.
  • Print the value from cm that represents the actual 1s that were predicted as 1s (true positives).

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

from sklearn.metrics import ____

# Create predictions
test_predictions = rfc.____(____)

# Create and print the confusion matrix
cm = ____(____, ____)
print(cm)

# Print the true positives (actual 1s that were predicted 1s)
print("The number of true positives is: {}".format(cm[____, ____]))
Kodu Düzenle ve Çalıştır