Sentiment analysis

Python में सोशल मीडिया डेटा का विश्लेषण

Alex Hanna

Computational Social Scientist

Sentiment analysis समझना

  • विधि
    • डॉक्यूमेंट में पॉजिटिव/नेगेटिव शब्द गिनना
    • पूरे डॉक्यूमेंट की पॉजिटिविटी/नेगेटिविटी आँकना
  • उपयोग
    • किसी कंपनी, प्रोडक्ट, राजनेता, या नीति पर प्रतिक्रियाएँ विश्लेषित करना
Python में सोशल मीडिया डेटा का विश्लेषण

Sentiment analysis टूल्स

  • VADER SentimentIntensityAnalyzer()
    • Natural Language Toolkit (nltk) का हिस्सा
    • ट्वीट जैसे छोटे टेक्स्ट के लिए अच्छा
    • खास शब्दों के sentiment को मापता है (जैसे angry, happy)
    • इमोजी (😀) और कैपिटलाइज़ेशन (Nice बनाम NICE) का असर भी देखता है
Python में सोशल मीडिया डेटा का विश्लेषण

Sentiment analysis लागू करना

from nltk.sentiment.vader import SentimentIntensityAnalyzer

sid = SentimentIntensityAnalyzer()
sentiment_scores = tweets['text'].apply(sid.polarity_scores)
Python में सोशल मीडिया डेटा का विश्लेषण

Sentiment स्कोर की व्याख्या

  • प्रोसेस के हिस्से के रूप में ट्वीट पढ़ना
    • क्या इसमें face validity है? (यानी, क्या यह मेरी पॉजिटिव/नेगेटिव समझ से मेल खाता है?)
Python में सोशल मीडिया डेटा का विश्लेषण

Sentiment स्कोर की व्याख्या

tweet1 = 'RT @jeffrey_heer: Thanks for inviting me, and thanks 
for the lovely visualization of the talk! ...'
print(sid.polarity_scores(tweet1))
{'neg': 0.0, 'neu': 0.496, 'pos': 0.504, 'compound': 0.9041}
tweet2 = 'i am having problems with google play music'
print(sid.polarity_scores(tweet2)
{'neg': 0.267, 'neu': 0.495, 'pos': 0.238, 'compound': -0.0772}
Python में सोशल मीडिया डेटा का विश्लेषण

Sentiment औसत निकालना

sentiment = sentiment_scores.apply(lambda x: x['compound'])

sentiment_fb = sentiment[check_word_in_tweet('facebook', tweets)] .resample('1 min').mean() sentiment_gg = sentiment[check_word_in_tweet('google', tweets)] .resample('1 min').mean()
Python में सोशल मीडिया डेटा का विश्लेषण

Sentiment स्कोर प्लॉट करना

plt.plot(
    sentiment_fb.index.minute, 
    sentiment_fb, color = 'blue'
    )
plt.plot(
    sentiment_g.index.minute, 
    sentiment_gg, color = 'green'
    )   
plt.xlabel('Minute')
plt.ylabel('Sentiment')
plt.title('Sentiment of companies')
plt.legend(('Facebook', 'Google'))
plt.show()

Facebook बनाम Google का sentiment

Python में सोशल मीडिया डेटा का विश्लेषण

अभ्यास करते हैं!

Python में सोशल मीडिया डेटा का विश्लेषण

Preparing Video For Download...