Notebooks
A
Azure
Train Local

Train Local

how-to-use-azuremlazure-mldata-sciencenotebooktrain-localmachine-learningusing-mlflowtrack-and-monitor-experimentsazure-machine-learningdeep-learningazuremlazure-ml-notebooksazure

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License.

Impressions

Use MLflow with Azure Machine Learning for Local Training Run

This example shows you how to use mlflow tracking APIs together with Azure Machine Learning services for storing your metrics and artifacts, from local Notebook run. You'll learn how to:

  1. Set up MLflow tracking URI so as to use Azure ML
  2. Create experiment
  3. Train a model on your local computer while logging metrics and artifacts
  4. View your experiment within your Azure ML Workspace in Azure Portal.

Prerequisites and Set-up

Make sure you have completed the Configuration notebook to set up your Azure Machine Learning workspace and ensure other common prerequisites are met.

Install azureml-mlflow package before running this notebook. Note that mlflow itself gets installed as dependency if you haven't installed it yet.

	pip install azureml-mlflow

This example also uses scikit-learn and matplotlib packages. Install them:

	pip install scikit-learn matplotlib

Then, import necessary packages

[ ]

Set tracking URI

Set the MLflow tracking URI to point to your Azure ML Workspace. The subsequent logging calls from MLflow APIs will go to Azure ML services and will be tracked under your Workspace.

[ ]

Create Experiment

In both MLflow and Azure ML, training runs are grouped into experiments. Let's create one for our experimentation.

[ ]

Create training and test data set

This example uses diabetes dataset to build a simple regression model. Let's load the dataset and split it into training and test sets.

[ ]

Train while logging metrics and artifacts

Next, start a mlflow run to train a scikit-learn regression model. Note that the training script has been instrumented using MLflow to:

  • Log model hyperparameter alpha value
  • Log mean squared error against test set
  • Save the scikit-learn based regression model produced by training
  • Save an image that shows actuals vs predictions against test set.

These metrics and artifacts have been recorded to your Azure ML Workspace; in the next step you'll learn how to view them.

[ ]

You can open the report page for your experiment and runs within it from Azure Portal.

Select one of the runs to view the metrics, and the plot you saved. The saved scikit-learn model appears under outputs tab.

[ ]

Next steps

Try out these notebooks to learn more about MLflow-Azure Machine Learning integration:

[ ]