My Note on MLflow

Part 1: Concepts

  • Experiment
import mlflow

# Create an experiment name, which must be unique and case sensitive
experiment_id = mlflow.create_experiment("Social NLP Experiments")
experiment = mlflow.get_experiment(experiment_id)
print("Name: {}".format(experiment.name))
print("Experiment_id: {}".format(experiment.experiment_id))
print("Artifact Location: {}".format(experiment.artifact_location))
print("Tags: {}".format(experiment.tags))
print("Lifecycle_stage: {}".format(experiment.lifecycle_stage))
  • Runs
def print_auto_logged_info(r):
tags = {k: v for k, v in r.data.tags.items() if not k.startswith("mlflow.")}
artifacts = [f.path for f in MlflowClient().list_artifacts(r.info.run_id, "model")]
print("run_id: {}".format(r.info.run_id))
print("artifacts: {}".format(artifacts))
print("params: {}".format(r.data.params))
print("metrics: {}".format(r.data.metrics))
print("tags: {}".format(tags))
mlflow.autolog()
with mlflow.start_run() as run:
neigh = KNeighborsClassifier(n_neighbors=5)
neigh.fit(X,y)

print('active run_id: {}'.format(run.info.run_id))

print_auto_logged_info(mlflow.get_run(run_id=run.info.run_id))

Part 2: Experience

  1. When mlflow.autolog() is enabled, parameters/metrics will be kept automatically, and there is no need to use mlflow.log_param to keep the parameters unless the parameters are not within the model defined in sklearn
  2. when use mlflow.set_tracking_uri('file:/home/usr_name...') , you need to set the experiment id in mlflow_star_run
exp_id = mlflow.create_experiment("my_iris_classification_model")
with mlflow.start_run(experiment_id=exp_id) as run:
mlflow.pytorch.log_model(scripted_model, "model")

As a result, when you invoke mlflow ui, please indicate the uri location

mlflow ui --backend-store-uri file:/home/petra/mlrun_store

It is also possible to denote other information

--default-artifact-root file:/home/petra/mlrun_store \
--host 0.0.0.0 \
--port 5000

Part 3: Pattern

Reference

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Text preprocessing steps and universal pipeline

Visualization in TensorFlow: Summary and TensorBoard

Deploying GPT-2 Models in Custom Applications

Transformer Architecture: Attention Is All You Need

Review: Make your first GAN with Pytorch

Scaling DeepSpeech using Mixed Precision and KubeFlow

Word Embedding (Part II) : Intuition and (some) maths to understand end-to-end GloVe model

The Pareto principle — Game-changer to ML Engineers in 2022

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ifeelfree

ifeelfree

More from Medium

How to Build and Run your Entire End-to-end ML Life-cycle with Scalable Components

Save time by building a continuous training pipeline for ML. Part 1

Best Practices for MLOps Documentation

MLOps: Development in machine learning