불용어

Python으로 배우는 Sentiment Analysis

Violeta Misheva

Data Scientist

불용어란? 어떻게 찾을까?

불용어: 너무 자주 나타나 정보성이 낮은 단어

  • 대부분 언어에 불용어 목록이 있습니다

      {'the', 'a', 'an', 'and', 'but', 'for', 'on', 'in', 'at' ...}
    
  • 맥락이 중요합니다

      {'movie', 'movies', 'film', 'films', 'cinema'}
    
Python으로 배우는 Sentiment Analysis

워드클라우드와 불용어

  • 불용어를 제거하지 않은 워드클라우드 불용어 미제거 워드클라우드
  • 불용어 제거된 워드클라우드 불용어 제거 워드클라우드
Python으로 배우는 Sentiment Analysis

워드클라우드에서 불용어 제거

# 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')
Python으로 배우는 Sentiment Analysis

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)
Python으로 배우는 Sentiment Analysis

연습해 봅시다!

Python으로 배우는 Sentiment Analysis

Preparing Video For Download...