Skip to content

Instantly share code, notes, and snippets.

@gvyshnya
Created April 21, 2021 14:14
Show Gist options
  • Save gvyshnya/a3627126e8651e664002a6a2bcb4d9a6 to your computer and use it in GitHub Desktop.
Save gvyshnya/a3627126e8651e664002a6a2bcb4d9a6 to your computer and use it in GitHub Desktop.
Hyperopt Ensemble Search function
def ensemble_search(params):
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=22)
model = EnsembleModel(params)
evaluation = [(X_test, y_test)]
model.fit(X_train, y_train,
eval_set=evaluation,
early_stopping_rounds=100, verbose=False)
val_preds = model.predict(X_test)
fpr, tpr, thresholds = roc_curve(y_test, val_preds, pos_label = 1)
auc_score = auc(fpr, tpr)
neg_auc_score = -1 * auc_score
return {"loss": neg_auc_score, "status": STATUS_OK}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment