फिर से Confusion matrices
Python में confusion matrix बनाना आसान है. सबसे बड़ी चुनौती उसके orientation (दिशा/व्यवस्था) को सही से समझना होगी. यह अभ्यास सुनिश्चित करता है कि आप confusion matrices के sklearn इम्प्लीमेंटेशन को समझें. यहाँ, आपने tic_tac_toe डेटासेट पर rfc नाम का एक random forest मॉडल बनाया है जो Player One के लिए 0 (हार) या 1 (जीत) के outcomes की भविष्यवाणी करता है.
नोट: यदि आप किसी और वेबसाइट पर या किसी दूसरी प्रोग्रामिंग भाषा में confusion matrices के बारे में पढ़ते हैं, तो मान उल्टे भी हो सकते हैं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Model Validation
अभ्यास निर्देश
- Confusion matrices बनाने के लिए
sklearnका फंक्शन इम्पोर्ट करें. - मॉडल
rfcका उपयोग करके test सेटX_testपर कैटेगरी प्रेडिक्शंस बनाएँ. sklearnका उपयोग करके एक confusion matrix बनाएँ.cmसे वह मान प्रिंट करें जो वास्तविक 1s को दर्शाता है जिन्हें 1 के रूप में ही प्रेडिक्ट किया गया था (true positives).
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
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[____, ____]))