Skip to content

Latest commit

 

History

History
231 lines (171 loc) · 12.6 KB

Dec 26 2020 - Connecting Azure Machine Learning Services Workspace and Azure Databricks.md

File metadata and controls

231 lines (171 loc) · 12.6 KB

Dec 26 2020 - Connecting Azure Machine Learning Services Workspace and Azure Databricks

Azure Databricks repository is a set of blogposts as a Advent of 2020 present to readers for easier onboarding to Azure Databricks!

Series of Azure Databricks posts:

Yesterday we looked into GraphFrames in Azure Databricks and the capabilities of calculating graph data.

Today we will look into Azure Machine Learning services.

What is Azure Machine Learning? It is a cloud-based environment you can use to train, deploy, automate, manage, and track ML models. It can be used for any kind of machine learning, from classical ML to deep learning, supervised, and unsupervised learning.

It supports Python and R code with the SDK and also gives you possibility to use Azure Machine Learning studio designer for "drag&drop" and no-code option. It supports also out-of-the-box tracking experiment, for prediction model workflow, managing, deploying and monitoring models with Azure Machine Learning.

Login to your Azure Portal and select the Databricks services. On the main page of Databricks service in Azure Portal, select "Link Azure ML workspace"

After selecting "Link Azure ML workspace", you will be prompted to add additional information, mainly because we are connecting two separate services.

And many of these should already be available from previous days (Key Vault, Store Account, Container Registry). You should only create a new application insights.

Click Review + create and Create.

Once completed you can download the deployment script or go directly to resource.

Among the resources, one new resource will be created for you. Go to this resource. You will see, that you will be introduced to Machine Learning Workspace and you can launch Studio.

Since this is the first time setup of this new workspace that has connection to Azure Databricks, you will be prompted additional information about the Active Directory account:

Hit that "Get started" button to launch the Studio.

You will be presented with a brand new Machine Learning Workspace. After you instantiate your workspace, MLflow Tracking is automatically set to be tracked in all of the following places:

  • The linked Azure Machine Learning workspace.
  • Your original ADB workspace.

All your experiments land in the managed Azure Machine Learning tracking service.

Now go to Azure Databricks and add some additional packages. In Azure Databricks under your cluster that we already used for MLflow, install package azureml-mlflow using PyPI.

Linking your ADB workspace to your Azure Machine Learning workspace enables you to track your experiment data in the Azure Machine Learning workspace.

The following code should be in your experiment notebook IN AZURE DATABRICKS (!) to get your linked Azure Machine Learning workspace.

import mlflow
import mlflow.azureml
import azureml.mlflow
import azureml.core

from azureml.core import Workspace

#Your subscription ID that you are running both Databricks and ML Service
subscription_id = 'subscription_id'

# Azure Machine Learning resource group NOT the managed resource group
resource_group = 'resource_group_name' 

#Azure Machine Learning workspace name, NOT Azure Databricks workspace
workspace_name = 'workspace_name'  

# Instantiate Azure Machine Learning workspace
ws = Workspace.get(name=workspace_name,
                   subscription_id=subscription_id,
                   resource_group=resource_group)

#Set MLflow experiment. 
experimentName = "/Users/{user_name}/{experiment_folder}/{experiment_name}" 
mlflow.set_experiment(experimentName) 

If you want your models to be tracked and monitored only in Azure Machine Learning service, add these two lines in Databricks notebook:

uri = ws.get_mlflow_tracking_uri()
mlflow.set_tracking_uri(uri)

Tomorrow we will look how to connect to your Azure databricks Service from your client machine or on-prem machine.

Complete set of code and the Notebook is available at the Github repository.

Happy Coding and Stay Healthy!