शुरू करेंमुफ़्त में शुरू करें

चार श्रेणियों का मूल्यांकन

Confusion matrix चार प्रकार के outcomes देखने का सबसे सीधा टूल है: true positives (TP), false positives (FP), true negatives (TN), और false negatives (FN). इस अभ्यास में, आप sklearn का standard decision tree classifier DecisionTreeClassifier() sample click डेटा पर उपयोग करेंगे और इन चार श्रेणियों के अनुसार outcomes का breakdown निकालेंगे.

आपके workspace में pandas मॉड्यूल pd के रूप में उपलब्ध है और sample DataFrame df के रूप में लोड है. फीचर्स X में और target y में उपयोग हेतु लोड हैं. इसके अलावा, sklearn.tree से DecisionTreeClassifier उपलब्ध है.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Python में Machine Learning के साथ CTR प्रेडिक्शन

पाठ्यक्रम देखें

अभ्यास निर्देश

  • X और y के लिए training और testing splits प्राप्त करें.
  • एक decision tree classifier परिभाषित करें और मॉडल को fit करके predictions y_pred निकालें.
  • Confusion matrix का उपयोग करके प्रत्येक outcome श्रेणी की गिनती प्राप्त करें, जहाँ 1 positive (click) और 0 negative (non-click) है.
  • उदाहरण के लिए: true negatives [0,0] होंगे और true positives [1,1] होंगे.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Set up classifier using training data to predict test data
X_train, X_test, y_train, y_test = ____(
  X, y, test_size = .2, random_state = 0)
clf = ____
y_pred = clf.____(X_train, y_train).____(X_test) 

# Define confusion matrix and four categories
conf_matrix = ____(y_test, y_pred)
tn = conf_matrix[____][____]
fp = conf_matrix[____][____]
fn = conf_matrix[____][____]
tp = conf_matrix[____][____]

print("TN: %s, FP: %s, FN: %s, TP: %s" %(tn, fp, fn, tp))
कोड संपादित करें और चलाएँ