Stop word

Analisis Sentimen dengan Python

Violeta Misheva

Data Scientist

Apa itu stop word dan cara menemukannya?

Stop word: kata yang terlalu sering muncul dan kurang informatif

  • Daftar stop word ada di sebagian besar bahasa

      {'the', 'a', 'an', 'and', 'but', 'for', 'on', 'in', 'at' ...}
    
  • Konteks berpengaruh

      {'movie', 'movies', 'film', 'films', 'cinema'}
    
Analisis Sentimen dengan Python

Stop word pada word cloud

  • Word cloud tanpa menghapus stop word Word cloud tanpa menghapus stop word
  • Word cloud setelah menghapus stop word Word cloud setelah menghapus stop word
Analisis Sentimen dengan Python

Hapus stop word dari word cloud

# 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')
Analisis Sentimen dengan Python

Stop word dengan 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)
Analisis Sentimen dengan Python

Ayo berlatih!

Analisis Sentimen dengan Python

Preparing Video For Download...