Pengantar MLflow
Weston Bassler
Senior MLOps Engineer

train.pymlflow.start_run()
import mlflow
# Mulai run
mlflow.start_run()
<ActiveRun: >
# Akhiri run
mlflow.end_run()
import mlflow # Set eksperimen mlflow.set_experiment("My Experiment") # Mulai run run = mlflow.start_run()# Cetak info run run.info
<RunInfo: artifact_uri='./mlruns/0/9de5df4d19994546b03dce09aefb58af/artifacts',
end_time=None, experiment_id='31', lifecycle_stage='active',
run_id='9de5df4d19994546b03dce09aefb58af', run_name='big-owl-145',
run_uuid='9de5df4d19994546b03dce09aefb58af', start_time=1676838126924,
status='RUNNING', user_id='user'>
Metrik
log_metric("accuracy", 0.90)log_metrics({"accuracy": 0.90, "loss": 0.50})Parameter
log_param("n_jobs", 1)log_params({"n_jobs": 1, "fit_intercept": False})Artefak
log_artifact("file.py")log_artifacts("./directory/")import mlflow # Set eksperimen mlflow.set_experiment("LR Experiment")# Mulai run mlflow.start_run()# Kode pelatihan model lr = LogisticRegression(n_jobs=1) # Kode evaluasi model lr.fit(X, y) score = lr.score(X, y)
# Catat metrik
mlflow.log_metric("score", score)
# Catat parameter
mlflow.log_param("n_jobs", 1)
# Catat artefak
mlflow.log_artifact("train_code.py")


Pengantar MLflow