Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- matplotlib
- len()
- Dictionary
- del
- 최솟값
- 덴드로그램
- 반복문
- data
- pandas
- dendrogram
- string
- Python
- hierarchical_clustering
- nan
- count()
- numpy
- sklearn
- 분류 결과표
- IN
- DataAccess
- Machine Learning
- insert()
- DataFrame
- list
- function
- append()
- analizer
- wcss
- elbow method
- 최댓값
Archives
- Today
- Total
개발공부
WordCloud 라이브러리 사용법, STOPWORDS(불용어) 처리, 배경 색, 배경 모양(mask) 설정 본문
Python/Machine Learning
WordCloud 라이브러리 사용법, STOPWORDS(불용어) 처리, 배경 색, 배경 모양(mask) 설정
mscha 2022. 5. 11. 18:09WordCloud
wordcloud 라이브러리가 제공하고 많이 나온 단어를 시각화 할 수 있다.
STOPWORDS
불용어라고 한다.
필요없는 단어를 지칭한다.
예제
아래와같은 리뷰 문자열이있다.

from wordcloud import WordCloud, STOPWORDS
import matplotlib.pyploy as plt
my_stopwords = STOPWORDS
# 불용어에 Alexa도 추가한다.
my_stopwords.add('Alexa')
# 배경색은 white 불용어는 my_stopwords
wc = WordCloud(background_color='white', stopwords= my_stopwords)
# 워드클라우드 생성
wc.generate(reviews)

plt.imshow(wc)
plt.axis('off')
plt.show()

배경모양 mask 설정
이미지 파일을 하나 가져와서 이를 마스크로 설정해보자
from PIL import Image
img = Image.open('data/cat.jpg')
img_mask = np.array(img)
WordCloud()의 파라미터에 mask = img_mask를 해준다.
from wordcloud import WordCloud, STOPWORDS
import matplotlib.pyploy as plt
my_stopwords = STOPWORDS
# 불용어에 Alexa도 추가한다.
my_stopwords.add('Alexa')
# 배경색은 white 불용어는 my_stopwords
wc = WordCloud(background_color='white', stopwords= my_stopwords, mask = img_mask)
# 워드클라우드 생성
wc.generate(reviews)
plt.figure(figsize=(10, 10))
plt.imshow(wc)
plt.axis('off')
plt.show()

'Python > Machine Learning' 카테고리의 다른 글
| 아이템 기반 협업 필터링(Item based collaborative filtering), corr()의 min_peiods 파라미터 (0) | 2022.05.13 |
|---|---|
| Prophet 라이브러리 사용법 (0) | 2022.05.12 |
| 문자열 데이터를 숫자로 바꿔주는 CountVectorizer 와 analyzer 파라미터, fit, transform (0) | 2022.05.11 |
| 문자열 데이터의 구두점과 Stopwords(불용어) 제거하기 (0) | 2022.05.11 |
| Grid Search란 ? sklearn 라이브러리의 GridSearchCV 사용법 (0) | 2022.05.11 |