if __name__ == "__main__":
# load, split steps
...
# create experiment
my_exp = mlflow.set_experiment("sklearn_experiment")
# start MLflow run
with mlflow.start_run(experiment_id=my_exp.experiment_id):
# Train model
...
# Log model hyperparameters
mlflow.log_params({"n_estimators": n_estimators,
"max_depth": max_depth})
# Log performance metrics
mlflow.log_metrics({"F1 score": f1,
"Accuracy": accuracy,
"Precision": precision})
# log model
mlflow.sklearn.log_model(rf_model, "model")
Main block
Dictionary
mapping