from sklearn.ensemble import RandomForestClassifier, HistGradientBoostingClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_auc_score
from sklearn.pipeline import Pipeline
from sklearn.impute import SimpleImputer
models = {
'log_reg': LogisticRegression(max_iter=1000, class_weight='balanced'),
'random_forest': RandomForestClassifier(n_estimators=400, max_depth=None, random_state=42, n_jobs=-1),
'hist_gbm': HistGradientBoostingClassifier(max_depth=6, learning_rate=0.05, random_state=42),
}
for name, model in models.items():
pipeline = Pipeline([
('imputer', SimpleImputer(strategy='median')),
('model', model),
])
pipeline.fit(X_train, y_train)
predictions = pipeline.predict_proba(X_valid)[:, 1]
auc = roc_auc_score(y_valid, predictions)
print(name, round(auc, 4))