Skip to content

MLflow example to track Parameters and Metrics by using MLproject Functionality

License

Notifications You must be signed in to change notification settings

felix-exel/mlflow

Repository files navigation

MLflow example to track Parameter and Metrics by using MLproject Functionality

This MLflow example uses a simple LSTM-based time series forecasting model in TensorFlow 2 to demonstrate the Tracking and MLproject Functionality.
The Dataset can be found here: https://archive.ics.uci.edu/ml/datasets/individual+household+electric+power+consumption
Related Blog Post: https://www.novatec-gmbh.de/blog/mlflow-tracking-von-parametern-und-metriken/

Requirements

  • Mlflows MLproject will build a conda environment from the conda.yaml file at runtime. Therefore Anaconda or Miniconda must be installed.
  • MLflow must be installed: pip install mlflow
  • MLflow will look for a git executable to track the git commit for every experiment. To disable this:
    export GIT_PYTHON_REFRESH=quiet

Quick Start

MLflow Server with Docker

If docker and docker-compose is installed, use docker-compose.yaml to start a MLflow server and MySQL backend:
docker-compose up -d
Set environment variables for MLflow:
export MLFLOW_TRACKING_URI=mysql+pymysql://mlflow:mlflow@localhost:3306/mlflow
export MLFLOW_ARTIFACT_URI=http://localhost:5000
Start the MLflow Experiments:
mlflow run .

MLflow Server with SQLite

To use a SQLite backend and to start a local MLflow server, change the directory to the repository and use:
mlflow server --backend-store-uri sqlite:///mlflow.db --default-artifact-root ./mlruns --host 0.0.0.0
Set environment variables for MLflow:
export MLFLOW_TRACKING_URI=sqlite:///mlflow.db
export MLFLOW_ARTIFACT_URI=http://localhost:5000
Start the MLflow Experiments:
mlflow run .

Access the MLflow Dashboard: http://localhost:5000

Jupyter Notebook

There is a Jupyter Notebook available to explore the code in detail. For this purpose create a new conda environment from the conda.yaml, activate the environment and start a jupyter server.