Mencatat eksperimen di MLflow

Machine Learning Ujung ke Ujung

Joshua Stapleton

Machine Learning Engineer

MLflow

Tanpa MLflow...

  • Banyak run eksperimen tak terlacak dan berantakan
  • Run tidak seragam, sulit dibandingkan
  • Run tidak dapat direproduksi, hilang

Dengan MLflow...

  • Run eksperimen terlacak dan terorganisir
  • Perbandingan antar run yang distandardisasi
  • Run dapat direproduksi
  • Berbagi, menerapkan model
Machine Learning Ujung ke Ujung

Membuat eksperimen

mlflow.set_experiment()

  • Menetapkan nama eksperimen
  • Menyediakan workspace untuk run eksperimen

 

Penggunaan:

import mlflow

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

Menjalankan eksperimen

# 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
Machine Learning Ujung ke Ujung

Mengambil data eksperimen

 

mlflow.get_run(run_id)

  • Metadata untuk run tertentu

 

mlflow.search_runs()

  • Mengembalikan DataFrame metrik untuk banyak run

Penggunaan:

# 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}
Machine Learning Ujung ke Ujung

UI MLflow

 

Dasbor eksperimen MLflow

 

Contoh halaman eksperimen MLflow

Machine Learning Ujung ke Ujung

UI MLflow (lanj.)

 

Grafik contoh menunjukkan peningkatan metrik

 

Perbandingan metrik antar run

Machine Learning Ujung ke Ujung

Sumber MLflow

  • Pengantar MLflow Pengantar MLflow
  • Situs resmi MLflow Situs resmi MLflow
Machine Learning Ujung ke Ujung

Ayo berlatih!

Machine Learning Ujung ke Ujung

Preparing Video For Download...