반응형
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 | 29 | 30 |
Tags
- 재귀함수
- C언어
- 데이터전문기관
- CES 2O21 참가
- web 용어
- 자료구조
- inorder
- cudnn
- vscode
- web 개발
- Keras
- paragraph
- html
- web
- java역사
- classification
- pycharm
- web 사진
- 웹 용어
- 대이터
- 결합전문기관
- bccard
- tensorflow
- discrete_scatter
- 머신러닝
- broscoding
- postorder
- mglearn
- KNeighborsClassifier
- CES 2O21 참여
Archives
- Today
- Total
bro's coding
sklearn.feature_extraction.text.CountVectorizer.min_df변화 관찰 본문
[AI]/python.sklearn
sklearn.feature_extraction.text.CountVectorizer.min_df변화 관찰
givemebro 2020. 4. 28. 09:57반응형
(속성(단어) 줄이기)
단어집에서 min_df 이하의 횟수 만큼 나온 단어들을 제거
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import BernoulliNB
num_of_words=[]
scores_BernoulliNB=[]
min_df=range(1,10)
for df in min_df:
vect=CountVectorizer(min_df=df)
vect.fit(text_train)
num_of_words.append(len(vect.get_feature_names()))
X_train=vect.transform(text_train)
X_test=vect.transform(text_test)
model=BernoulliNB()
model.fit(X_train,y_train)
scores_BernoulliNB.append(model.score(X_test,y_test))
# visualization
import matplotlib.pyplot as plt
plt.subplot(1,2,1)
plt.plot(num_of_words,'b:o')
plt.xticks(min_df)
plt.subplot(1,2,2)
plt.plot(scores_BernoulliNB,'b:o')
plt.yticks(rotation=-50)
반응형
'[AI] > python.sklearn' 카테고리의 다른 글
sklearn.feature_extraction.text.TfidfTransformer.LogisticRegression적용 (0) | 2020.04.28 |
---|---|
sklearn.feature_extraction.text.TfidfTransformer (0) | 2020.04.28 |
sklearn.feature_extraction.text.CountVectorizer.stop_words적용 (0) | 2020.04.28 |
sklearn.feature_extraction.text.CountVectorizer.max_df변화 관찰 (0) | 2020.04.28 |
sklearn.textdata.BernoulliNB적용 (0) | 2020.04.28 |
sklearn.textdata.LogisticRegression적용 (0) | 2020.04.27 |
sklearn.textdata.단어집과 문장 대조하기 (0) | 2020.04.27 |
sklearn.feature_extraction.text.CountVectorizer (0) | 2020.04.27 |
Comments