반응형
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
- 결합전문기관
- CES 2O21 참여
- java역사
- web 용어
- vscode
- discrete_scatter
- mglearn
- 웹 용어
- classification
- broscoding
- web 개발
- web
- KNeighborsClassifier
- html
- C언어
- bccard
- tensorflow
- pycharm
- 자료구조
- paragraph
- 대이터
- 재귀함수
- postorder
- cudnn
- Keras
- 머신러닝
- inorder
- 데이터전문기관
- web 사진
- CES 2O21 참가
Archives
- Today
- Total
bro's coding
sklearn.pipeline.Pipeline 본문
반응형
편의성을 위해 사용
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import MinMaxScaler
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
# data 준비
iris=load_iris()
X_train,X_test,y_train,y_test=train_test_split(iris.data,iris.target)
from sklearn.preprocessing import MinMaxScaler
from sklearn.decomposition import PCA
from sklearn.neighbors import KNeighborsClassifier
# *****
from sklearn.pipeline import Pipeline
# *****
pipeline 정의
pipe = Pipeline([('scaler',MinMaxScaler()),('pca',PCA(2)),('model',KNeighborsClassifier())])
# train
pipe.fit(X_train,y_train)
# score 확인
s_train=pipe.score(X_train,y_train)
s_test=pipe.score(X_test,y_test)
display(s_test,s_train)
# 0.8947368421052632
# 0.9732142857142857
# 중간 과정 확인
pipe.steps
'''
[('scaler', MinMaxScaler(copy=True, feature_range=(0, 1))),
('pca',
PCA(copy=True, iterated_power='auto', n_components=2, random_state=None,
svd_solver='auto', tol=0.0, whiten=False)),
('model',
KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',
metric_params=None, n_jobs=1, n_neighbors=5, p=2,
weights='uniform'))]
'''
반응형
'[AI] > python.sklearn' 카테고리의 다른 글
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 |
sklearn.base.BaseEstimator, ClassifierMixin(분류기 만들기) (0) | 2020.04.27 |
sklearn.precision,recall (0) | 2020.04.24 |
sklearn.metrics.confusion_matrix(판정표) (0) | 2020.04.24 |
sklearn.model_selection.cross_val_score.LeaveOneOut (0) | 2020.04.24 |
sklearn.cross_val_score.models (0) | 2020.04.24 |
Comments