- 여러 단계의 머신러닝 프로세스 (전처리의 각 단계, 모델생성, 학습) 처리 과정을 설정하여 한번에 처리되도록 한다
- 종류
- 전처리작업 파이프라인
- 전체 프로세스 파이프라인
from sklearn.pipeline import Pipeline
order = [
('scaler', StandardScaler()),
('svm',SVC())
]
pipeline = Pipeline(order, verbose=True)
pipeline.fit(Feature, Label)
pred_train = pipeline.predict(X_train)
pred_test = pipeline.predict(X_test)
order = [
('scaler', StandardScaler()),
('svc', SVC(random_state=0))
]
pipeline = Pipeline(order)
param = {
"svc__C":[0.001, 0.01, 0.1, 1, 10],
"svc__gamma":[0.001, 0.01, 0.1, 1, 10]
}
gs = GridSearchCV(pipeline,
param,
scoring='accuracy',
cv=4,
n_jobs=-1)
gs.fit(Feature, Label)
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import MinMaxScaler
pipeline2 = make_pipeline(MinMaxScaler(), SVC(C=100))
pipeline2.fit(Feature, Label).score(New_Feature, New_Label)