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

Feature selection के साथ Naive Bayes ट्रेन करना

अब आप Chapter 3 के अंत में चलाए गए Naive Bayes टेक्स्ट क्लासिफिकेशन मॉडल को फिर से चलाएँगे, लेकिन पिछले अभ्यास में चुने गए सेलेक्शन के साथ: volunteer डेटासेट के title और category_desc कॉलम.

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

Python में Machine Learning के लिए Preprocessing

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

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

  • filtered_text टेक्स्ट वेक्टर और y लेबल (जो category_desc लेबल हैं) पर train_test_split() का उपयोग करें, और असमान class distribution के कारण y सेट को stratify पैरामीटर में पास करें.
  • nb Naive Bayes मॉडल को X_train और y_train पर फिट करें.
  • टेस्ट सेट accuracy को nb के लिए कैलकुलेट करें.

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

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

# Split the dataset according to the class distribution of category_desc
X_train, X_test, y_train, y_test = ____(____.toarray(), ____, stratify=____, random_state=42)

# Fit the model to the training data
nb.____

# Print out the model's accuracy
print(nb.____)
कोड संपादित करें और चलाएँ