Skip to content

Instantly share code, notes, and snippets.

@jrzaurin
Last active March 11, 2019 10:38
Show Gist options
  • Save jrzaurin/115fb3c2a266be7d0a0af82998ea500b to your computer and use it in GitHub Desktop.
Save jrzaurin/115fb3c2a266be7d0a0af82998ea500b to your computer and use it in GitHub Desktop.
if not Path('mlruns').exists():
client = MlflowClient()
n_experiments=0
elif not reuse_experiment:
client = MlflowClient()
n_experiments = len(client.list_experiments())
experiment_name = 'experiment_' + str(n_experiments)
client.create_experiment(name=experiment_name)
with mlflow.start_run(experiment_id=n_experiments):
model = lgb.LGBMClassifier(**best)
model.fit(X,y,
feature_name=colnames,
categorical_feature=categorical_columns
)
for name, value in best.items():
mlflow.log_param(name, value)
mlflow.log_metric('binary_logloss', trials.best_trial['result']['loss'])
mlflow.sklearn.log_model(model, "model")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment