End-to-End Machine Learning
Joshua Stapleton
Machine Learning Engineer
Without MLflow...
With MLflow...
mlflow.set_experiment()
Usage:
import mlflow
# Set an experiment name, which is a workspace for your runs
mlflow.set_experiment("Heart Disease Classification")
# Start a new run in this experiment with mlflow.start_run(): # Train a model, get the prediction accuracy logistic_model = LogisticRegression()
# Log parameters, eg: mlflow.log_param("n_estimators", logistic_model.n_estimators)
# Log metrics (accuracy in this case) mlflow.log_metric("accuracy", logistic_model.accuracy)
# Print out metrics print("Model accuracy: %.3f" % accuracy)
Model accuracy: 0.96
mlflow.get_run(run_id)
mlflow.search_runs()
Usage:
# Fetch the run data and print params
run_data = mlflow.get_run(run_id)
print(run_data.data.params)
print(run_data.data.metrics)
# Search all runs in experiment
exp_id = run_data.info.experiment_id
runs_df = mlflow.search_runs(exp_id)
{'epochs': '20', 'accuracy': 0.95}
End-to-End Machine Learning