Notice
Recent Posts
Recent Comments
Link
라일락 꽃이 피는 날
[Sklearn] 파이프라인 (pipeline) 본문
728x90
파이프라인 (pipeline)
from sklearn.pipeline import make_pipeline
elasticnet_pipeline = make_pipeline(
StandardScaler(),
ElasticNet(alpha=0.1, l1_ratio=0.2)
)
elasticnet_pred = elasticnet_pipeline.fit(x_train, y_train).predict(x_test)

polynomial features
다항식의 계수간 상호작용을 통해 새로운 feature를 생성한다.
예를들면, [a, b] 2개의 feature가 존재한다고 가정하고,
degree=2로 설정한다면, polynomial features 는 [1, a, b, a^2, ab, b^2] 가 된다.
from sklearn.preprocessing import PolynomialFeatures
poly = PolynomialFeatures(degree=2, include_bias=False)
poly_features = poly.fit_transform(x_train)[0]


poly_pipeline = make_pipeline(
PolynomialFeatures(degree=2, include_bias=False),
StandardScaler(),
ElasticNet(alpha=0.1, l1_ratio=0.2)
)
poly_pred = poly_pipeline.fit(x_train, y_train).predict(x_test)

728x90
'데이터 분석 > Python' 카테고리의 다른 글
| [Sklearn] 앙상블 (Ensemble) - 부스팅 (Boosting) (0) | 2021.05.17 |
|---|---|
| [Sklearn] 앙상블 (Ensemble) - 보팅 (Voting), 배깅 (Bagging) (0) | 2021.05.17 |
| [Sklearn] Scaler (0) | 2021.05.14 |
| [Sklearn] ElasticNet (0) | 2021.05.13 |
| [Sklearn] 규제 (Regularization) (0) | 2021.05.13 |