# AutoML 생성 노트북에서 가져온 코드를 기반으로 커스터마이징
# (실제 AutoML이 생성하는 코드의 구조 예시)
import mlflow
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.compose import ColumnTransformer
from xgboost import XGBClassifier
# AutoML이 생성한 전처리 파이프라인 (수정 가능)
preprocessor = ColumnTransformer(
transformers=[
("num", StandardScaler(), numerical_cols),
("cat", OneHotEncoder(handle_unknown="ignore"), categorical_cols),
]
)
# AutoML이 찾은 최적 하이퍼파라미터 (세밀 조정 가능)
model = Pipeline([
("preprocessor", preprocessor),
("classifier", XGBClassifier(
n_estimators=200, # AutoML 결과 기반
max_depth=6, # 직접 조정 가능
learning_rate=0.1,
min_child_weight=3,
subsample=0.8
))
])
# MLflow 자동 로깅
with mlflow.start_run(run_name="customized-automl-model"):
model.fit(X_train, y_train)
mlflow.sklearn.log_model(model, "model",
registered_model_name="catalog.schema.churn_model")