반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

sklearn.feature_extraction.text.CountVectorizer.stop_words적용 본문

[AI]/python.sklearn

sklearn.feature_extraction.text.CountVectorizer.stop_words적용

givemebro 2020. 4. 28. 10:33
반응형
# Stop_words 적용

from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import BernoulliNB


num_of_words=[]
scores_BernoulliNB=[]


vect=CountVectorizer(stop_words='english')


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))


display(num_of_words,scores_BernoulliNB)
[75600]
[0.8172]
반응형
Comments