एकाधिक टेक्स्ट कॉलम
इस अभ्यास में, आप एयरलाइन के Twitter डेटा के साथ काम जारी रखेंगे. आपके लिए tweets नामक डेटासेट इम्पोर्ट किया गया है.
कभी-कभी किसी डेटासेट में एक से अधिक टेक्स्ट कॉलम होते हैं और आप हर टेक्स्ट कॉलम के लिए एक न्यूमेरिक रिप्रेज़ेंटेशन बनाना चाहेंगे. यहाँ text कॉलम (जिसमें ट्वीट का बॉडी है) के अलावा एक दूसरा टेक्स्ट कॉलम negativereason भी है. इसमें वह कारण होता है जिसकी वजह से कस्टमर ने नकारात्मक रिव्यू दिया.
आपका काम दोनों कॉलम्स के लिए BOW रिप्रेज़ेंटेशन बनाना और ज़रूरी stop words निर्दिष्ट करना है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Sentiment Analysis
अभ्यास निर्देश
- vectorizer पैकेज और English stop words की डिफ़ॉल्ट सूची इम्पोर्ट करें.
- English stop words की डिफ़ॉल्ट सूची अपडेट करें और
my_stop_wordsसेट बनाएँ. - पहले vectorizer में stop words आर्ग्युमेंट को अपडेटेड सेट पर सेट करें, और दूसरे vectorizer में English stop words की डिफ़ॉल्ट सूची का उपयोग करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Import the vectorizer and default English stop words list
____
# Define the stop words
my_stop_words = ____._____(['airline', 'airlines', '@', 'am', 'pm'])
# Build and fit the vectorizers
vect1 = CountVectorizer(____=my_stop_words)
vect2 = CountVectorizer(____=____)
vect1.fit(tweets.text)
vect2.fit(tweets.negative_reason)
# Print the last 15 features from the first, and all from second vectorizer
print(vect1.get_feature_names()[-15:])
print(vect2.get_feature_names())