n-grams के साथ सूक्ष्म विश्लेषण

Python में Sentiment Analysis

Violeta Misheva

Data Scientist

Context मायने रखता है

I am happy, not sad.

I am sad, not happy.

  • किसी शब्द के आगे 'not' लगाना (negation) दिखाता है कि संदर्भ क्यों मायने रखता है.
Python में Sentiment Analysis

BOW से संदर्भ पकड़ना

  • Unigrams: सिंगल टोकन

  • Bigrams: टोकन की जोड़ियाँ

  • Trigrams: तीन-टोकन क्रम

  • n-grams: n टोकन की अनुक्रम

Python में Sentiment Analysis

BOW से संदर्भ पकड़ना

The weather today is wonderful.

  • Unigrams : { The, weather, today, is, wonderful }

  • Bigrams: {The weather, weather today, today is, is wonderful}

  • Trigrams: {The weather today, weather today is, today is wonderful}

Python में Sentiment Analysis

CountVectorizer के साथ n-grams

from sklearn.feature_extraction.text import CountVectorizer
vect = CountVectorizer(ngram_range=(min_n, max_n))
# Only unigrams
ngram_range=(1, 1)
# Uni- and bigrams
ngram_range=(1, 2)
Python में Sentiment Analysis

सबसे अच्छा n क्या है?

लंबी टोकन अनुक्रम
  • अधिक फीचर्स बनते हैं
  • Machine Learning मॉडलों की प्रिसिशन बढ़ती है
  • Overfitting का जोखिम
Python में Sentiment Analysis

Vocabulary size सेट करना

CountVectorizer(max_features, max_df, min_df)
  • max_features: देने पर vocabulary में सिर्फ सबसे आवृत्त शब्द शामिल होंगे
    • अगर max_features = None, तो सभी शब्द शामिल होंगे
  • max_df: निर्दिष्ट से अधिक आवृत्ति वाले terms को नज़रअंदाज़ करें
    • integer होने पर absolute count; float होने पर proportion
    • डिफ़ॉल्ट 1.0 है, यानी कोई term इग्नोर नहीं होता
  • min_df: निर्दिष्ट से कम आवृत्ति वाले terms को नज़रअंदाज़ करें
    • integer होने पर absolute count; float होने पर proportion
    • डिफ़ॉल्ट 1.0 है, यानी कोई term इग्नोर नहीं होता
Python में Sentiment Analysis

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

Python में Sentiment Analysis

Preparing Video For Download...