반응형
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
- 머신러닝
- 재귀함수
- CES 2O21 참가
- web 사진
- 대이터
- vscode
- web 용어
- 결합전문기관
- C언어
- web
- classification
- 데이터전문기관
- java역사
- broscoding
- discrete_scatter
- CES 2O21 참여
- postorder
- cudnn
- 웹 용어
- KNeighborsClassifier
- web 개발
- html
- 자료구조
- bccard
- Keras
- pycharm
- paragraph
- mglearn
- inorder
- tensorflow
Archives
- Today
- Total
bro's coding
sklearn.textdata.LogisticRegression적용 본문
반응형
https://broscoding.tistory.com/203
import numpy as np
# upload data file
imdb_tarin,imdb_test=np.load('imdb.npy')
# decode -> remove<br />
text_train=[s.decode().replace('<br />','') for s in imdb_tarin.data]
text_test=[s.decode().replace('<br .>','')for s in imdb_test.data]
y_train=imdb_tarin.target
y_test=imdb_test.target
from sklearn.feature_extraction.text import CountVectorizer
vect=CountVectorizer()
# train(train data)
vect.fit(text_train,y_train)
# define X_train
X_train=vect.transform(text_train)# sparse matrix
X_test=vect.transform(text_test)
from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LogisticRegression
# cross_val_score
scores=cross_val_score(LogisticRegression(C=1),X_test,y_test)
display(scores.mean())
# 0.8831598032887086
반응형
'[AI] > python.sklearn' 카테고리의 다른 글
sklearn.feature_extraction.text.CountVectorizer.stop_words적용 (0) | 2020.04.28 |
---|---|
sklearn.feature_extraction.text.CountVectorizer.max_df변화 관찰 (0) | 2020.04.28 |
sklearn.feature_extraction.text.CountVectorizer.min_df변화 관찰 (0) | 2020.04.28 |
sklearn.textdata.BernoulliNB적용 (0) | 2020.04.28 |
sklearn.textdata.단어집과 문장 대조하기 (0) | 2020.04.27 |
sklearn.feature_extraction.text.CountVectorizer (0) | 2020.04.27 |
sklearn.textdata.datasets.load_files (0) | 2020.04.27 |
sklearn.base.BaseEstimator, TransformerMixin(추정기 만들기) (0) | 2020.04.27 |
Comments