39. ch05. sklearn - 회귀 - 11. 파이프라인 (Pipeline) - 41. ch06. sklearn - 앙상블 - 01. 앙상블 학습의 이해
39. ch05. sklearn - 회귀 - 11. 파이프라인 (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)
mse_eval('Standard ElasticNet', elasticnet_pred, y_test)
elasticnet_no_pipeline = ElasticNet(alpha=0.1, l1_ratio=0.2)
no_pipeline_pred = elasticnet_no_pipeline.fit(x_train, y_train).predict(x_test)
mse_eval('No Standard ElasticNet', elasticnet_pred, y_test)
파이프라인 적용 안한것과 비교
40. ch05. sklearn - 회귀 - 12. 다항식 모델 (Polynomial Features)
Polynomial Features
다항식의 계수간 상호작용을 통해 새로운 feature를 생성
from sklearn.preprocessing import PolynomialFeatures
poly = PolynomialFeatures(degree=2, include_bias=False)
poly_features = poly.fit_transform(x_train)[0]
poly_features
x_train.iloc[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)
mse_eval('Poly ElasticNet', poly_pred, y_test)
41. ch06. sklearn - 앙상블 - 01. 앙상블 학습의 이해
패스트캠퍼스 데이터분석 강의 링크
bit.ly/3imy2uN
카테고리 없음