Experimente in MLflow protokollieren

End-to-End Machine Learning

Joshua Stapleton

Machine Learning Engineer

MLflow

Ohne MLflow …

  • Viele unprotokollierte, chaotische Runs
  • Unvergleichbare Runs
  • Nicht reproduzierbare, verlorene Runs

Mit MLflow …

  • Protokollierte, organisierte Runs
  • Vergleich standardisierter Runs
  • Reproduzierbare Runs
  • Modelle teilen, deployen
End-to-End Machine Learning

Experimente erstellen

mlflow.set_experiment()

  • Setzt den Experimentnamen
  • Bietet Workspace für Runs

 

Verwendung:

import mlflow

# Set an experiment name, which is a workspace for your runs
mlflow.set_experiment("Heart Disease Classification")
End-to-End Machine Learning

Experimente ausführen

# 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
End-to-End Machine Learning

Experimente abrufen

 

mlflow.get_run(run_id)

  • Metadaten zu einem bestimmten Run

 

mlflow.search_runs()

  • Gibt ein DataFrame mit Metriken mehrerer Runs zurück

Verwendung:

# 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

MLflow-UI

 

MLflow-Experiment-Dashboard

 

MLflow-Beispielseite für ein Experiment

End-to-End Machine Learning

MLflow-UI (Fortsetzung)

 

Beispielgrafik mit Metrik-Verbesserung

 

Beispiel: Metriken über Runs vergleichen

End-to-End Machine Learning

MLflow-Ressourcen

  • Einführung in MLflow Einführung in MLflow
  • Offizielle MLflow-Website Offizielle MLflow-Website
End-to-End Machine Learning

Lass uns üben!

End-to-End Machine Learning

Preparing Video For Download...