Bag-of-words

Python में Sentiment Analysis

Violeta Misheva

Data Scientist

Bag-of-words (BOW) क्या है?

 

  • किसी डॉक्युमेंट या डॉक्युमेंट्स के संग्रह (कॉर्पस) में शब्दों की उपस्थिति बताता है

  • शब्दों का एक शब्द-संग्रह बनाता है और उनकी मौजूदगी को मापता है

Python में Sentiment Analysis

Amazon प्रोडक्ट रिव्यू

Amazon प्रोडक्ट रिव्यू डेटासेट की टॉप 10 पंक्तियाँ

Python में Sentiment Analysis

BOW से सेंटिमेंट एनालिसिस: उदाहरण

This is the best book ever. I loved the book and highly recommend it!!!

{'This': 1, 'is': 1, 'the': 2 , 'best': 1 , 'book': 2, 
'ever': 1, 'I':1 , 'loved':1 , 'and': 1  , 'highly': 1,
'recommend': 1 , 'it': 1 }
  • शब्दों का क्रम और व्याकरण नियम खो जाते हैं!
Python में Sentiment Analysis

BOW का अंतिम परिणाम

  • आउटपुट कुछ ऐसा दिखेगा:

BOW के आउटपुट को दिखाती टॉप 5 पंक्तियों वाली तालिका

Python में Sentiment Analysis

CountVectorizer फंक्शन

import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
vect = CountVectorizer(max_features=1000) 
vect.fit(data.review)
X = vect.transform(data.review)
Python में Sentiment Analysis

CountVectorizer आउटपुट

X
<10000x1000 sparse matrix of type '<class 'numpy.int64'>' 
  with 406668 stored elements in Compressed Sparse Row format>

Python में Sentiment Analysis

वेक्टराइज़र को बदलना

# Transform to an array
my_array = X.toarray()
# Transform back to a DataFrame, assign column names
X_df = pd.DataFrame(my_array, columns=vect.get_feature_names())
Python में Sentiment Analysis

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

Python में Sentiment Analysis

Preparing Video For Download...