Stop words

Sentiment Analysis ด้วย Python

Violeta Misheva

Data Scientist

Stop words คืออะไร และจะค้นหาได้อย่างไร?

Stop words: คำที่ปรากฏบ่อยเกินไปและไม่ถือว่าให้ข้อมูลที่มีประโยชน์

  • มีรายการ stop words สำหรับภาษาส่วนใหญ่

      {'the', 'a', 'an', 'and', 'but', 'for', 'on', 'in', 'at' ...}
    
  • บริบทมีความสำคัญ

      {'movie', 'movies', 'film', 'films', 'cinema'}
    
Sentiment Analysis ด้วย Python

Stop words กับ word clouds

  • Word cloud โดยไม่ลบ stop words Word cloud โดยไม่ลบ stop words
  • Word cloud หลังลบ stop words แล้ว Word cloud หลังลบ stop words แล้ว
Sentiment Analysis ด้วย Python

ลบ stop words ออกจาก word clouds

# Import libraries
from wordcloud import WordCloud, STOPWORDS
import matplotlib.pyplot as plt
# Define the stopwords list
my_stopwords = set(STOPWORDS)
my_stopwords.update(["movie", "movies", "film", "films", "watch", "br"])
# Generate and show the word cloud
my_cloud = WordCloud(background_color='white', stopwords=my_stopwords).generate(name_string)
plt.imshow(my_cloud, interpolation='bilinear')
Sentiment Analysis ด้วย Python

Stop words กับ BOW

from sklearn.feature_extraction.text import CountVectorizer, ENGLISH_STOP_WORDS
# Define the set of stop words
my_stop_words = ENGLISH_STOP_WORDS.union(['film', 'movie', 'cinema', 'theatre'])
vect = CountVectorizer(stop_words=my_stop_words) 
vect.fit(movies.review)
X = vect.transform(movies.review)
Sentiment Analysis ด้วย Python

มาฝึกกันเถอะ!

Sentiment Analysis ด้วย Python

Preparing Video For Download...