Stop words के साथ Airline sentiment
आपको tweets नाम का एक डेटासेट दिया गया है, जिसमें ग्राहकों के एयरलाइंस के बारे में रिव्यू और sentiments हैं. इसमें दो कॉलम हैं: airline_sentiment और text, जहाँ sentiment positive, negative या neutral हो सकता है, और text ट्वीट का टेक्स्ट है.
इस अभ्यास में, आप BOW (Bag-of-Words) representation बनाएँगे, लेकिन stop words को ध्यान में रखते हुए. याद रखें कि stop words जानकारीपूर्ण नहीं होते और आप उन्हें हटाना चाहेंगे. ऐसा करने से vocabulary छोटी होगी और अंततः फीचर्स भी कम रहेंगे. यह भी ध्यान रखें कि हम डिफ़ॉल्ट stop words लिस्ट को अपने संदर्भ के अनुसार अतिरिक्त शब्दों से समृद्ध कर सकते हैं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Sentiment Analysis
अभ्यास निर्देश
- इंग्लिश stop words की डिफ़ॉल्ट लिस्ट इम्पोर्ट करें.
- दी गई लिस्ट
['airline', 'airlines', '@']के साथ डिफ़ॉल्ट stop words लिस्ट को अपडेट करकेmy_stop_wordsबनाएँ. - vectorizer में stop_words आर्ग्युमेंट निर्दिष्ट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Import the stop words
from sklearn.feature_extraction.text import CountVectorizer, ____
# Define the stop words
my_stop_words = ____.____(['airline', 'airlines', '@'])
# Build and fit the vectorizer
vect = CountVectorizer(____=my_stop_words)
vect.fit(tweets.text)
# Create the bow representation
X_review = vect.transform(tweets.text)
# Create the data frame
X_df = pd.DataFrame(X_review.toarray(), columns=vect.get_feature_names())
print(X_df.head())