COURSE 3: BUILD AND OPERATE MACHINE LEARNING SOLUTIONS WITH AZURE

Module 3:Orchestrate Pipelines And Deploy Real-Time Machine Learning Services With Azure Machine Learning 

MICROSOFT AZURE DATA SCIENTIST ASSOCIATE (DP-100) PROFESSIONAL CERTIFICATE

Complete Coursera Study Guide

Last updated:

INTRODUCTION – Orchestrate Pipelines And Deploy Real-Time Machine Learning Services With Azure Machine Learning 

Orchestrating machine learning training with pipelines is a crucial aspect of integrating DevOps practices into machine learning workflows. In this module, you’ll learn how to create, publish, and run pipelines to train models using Azure Machine Learning.

Additionally, you’ll gain skills in registering and deploying machine learning models with the Azure Machine Learning service. This comprehensive approach ensures that you can efficiently manage the entire lifecycle of your models, from development to deployment, within a scalable and reliable framework.

Learning Objectives

  • Create an Azure Machine Learning pipeline.
  • Publish an Azure Machine Learning pipeline.
  • Schedule an Azure Machine Learning pipeline.
  • Deploy a model as a real-time inferencing service.
  • Consume a real-time inferencing service.
  • Troubleshoot service deployment.

PRACTICE QUIZ: KNOWLEDGE CHECK

1. True or False?

Pipelines in Azure Machine Learning must not be confused with Azure DevOps pipelines as they are not the same and they do not work together.

  • True
  • False (CORRECT)

Correct: They shouldn’t be confused, but they are similar and they can work together so it’s perfectly feasible to have an Azure DevOps pipeline with a task that initiates an Azure Machine Learning pipeline, which in turn includes a step that trains a model based on a Scikit-Learn pipeline.

2. What is the term used for each task in the workflow of an Azure Machine learning pipeline?

  • Runs
  • Jobs
  • Functions
  • Steps (CORRECT)

Correct: Steps can be arranged sequentially or in parallel, enabling you to build sophisticated flow logic to orchestrate machine learning operations.

3. In what manner can the steps of a pipeline use compute targets? 

Select all that apply

  • Each step must be assigned a single compute target
  • Each step can run on a specific compute target. (CORRECT)
  • All steps will run on the same compute targets (CORRECT)

Correct: Each step can be run on a specific compute target, making it possible to combine different types of processing as required to achieve an overall goal.

Correct: This is one way of running the pipeline, but not the only one.

4. What should you use to pass data between steps in an Azure ML pipeline?

  • Variables 
  • Parameters
  • Objects (CORRECT)
  • Methods

Correct: You use objects, such as a OutputFileDatasetConfig object which you can view as an intermediary store for data that must be passed from a step to a subsequent step.

5. Which parameter should you use in the step configuration if you need to reuse the step?

  • allow_reuse = False
  • enable_reuse = True
  • allow_reuse = True (CORRECT)
  • enable_reuse = False

Correct: This parameter will allow the step to be reused.

6. Which object should you use if you want to define parameters for a pipeline?

  • PipelineParameter (CORRECT)
  • ParameterPipeline
  • AllowParameter
  • ImportParameter

Correct: To define parameters for a pipeline, create a PipelineParameter object for each parameter, and specify each parameter in at least one step.

PRACTICE QUIZ: KNOWLEDGE CHECK

1. What is inferencing in Azure Machine Learning?

  • Using a trained model to predict labels for new, untrained data (CORRECT)
  • Training a model to predict labels 
  • Using a trained model to predict labels for old data

Correct: Inferencing refers to the use of a trained model to predict labels for new data on which the model has not been trained.

2. What kind of compute targets can you use to deploy a model as a real-time web service?

Select all that apply.

  • Azure App Service Plan
  • Azure Container Instance (ACI) (CORRECT)
  • Azure Kubernetes Service (AKS) cluster (CORRECT)
  • Azure Function (CORRECT)
  • Local compute. (CORRECT)
  • Internet of Things (IoT) module (CORRECT)
  • Azure Machine Learning compute instance (CORRECT)

Correct: You can use this as a compute target for a real-time inference web service.

Correct: You can use this as a compute target for a real-time inference web service.

Correct: You can use this as a compute target for a real-time inference web service.

Correct: You can use this as a compute target for a real-time inference web service.

Correct: You can use this as a compute target for a real-time inference web service.

Correct: You can use this as a compute target for a real-time inference web service.

3. Which two functions must be included in the entry script of a model? Select all that apply.

  • dispatcher()
  • run()
  • run(raw_data) (CORRECT)
  • init() (CORRECT)

Correct: This function is called when new data is submitted to the service.

Correct: This function is called when the service is initialized.

4. True or False? 

If you’re using an AKS cluster as a compute target, you can define the cluster in the deployment configuration.

  • True
  • False (CORRECT)

Correct: If you are deploying to an AKS cluster, you must create the cluster and a compute target for it before deploying

5. In a production environment, you must restrict access to your services by applying authentication.

Which types of authentication can you use? Select all that apply.

  • Just-in-time (JIT)
  • Shared access signatures (SAS)
  • Key (CORRECT)
  • Token (CORRECT)

Correct: Requests are authenticated by specifying the key associated with the service.

Correct: Requests are authenticated by providing a JSON Web Token (JWT).

QUIZ: TEST PREP

1. You defined three steps named step1, step2, and step3 for a pipeline you want to create.

You now want to assign those steps to the pipeline and run it as an experiment.

Which of the SDK commands below can you use?

  • train_pipeline = Pipeline(workspace = ws, steps = [step1;step2;step3])
  • experiment = Experiment(workspace = ws, name = ‘training-pipeline’)
  • pipeline_run = experiment.submit(train_pipeline)
  • train_pipeline = Pipeline(workspace = ws, steps = [step1,step2,step3])
  • experiment = Experiment(workspace = ws, name = ‘training-pipeline’)
  • pipeline_run = experiment_submit(train_pipeline)
  • train_pipeline = Pipeline(workspace = ws, steps = [step1,step2,step3])
  • experiment = Experiment(workspace = ws)
  • pipeline_run = experiment.submit(train_pipeline)
  • train_pipeline = Pipeline(workspace = ws, steps = [step1,step2,step3]) (CORRECT)
  • experiment = Experiment(workspace = ws, name = ‘training-pipeline’)
  • pipeline_run = experiment.submit(train_pipeline)

Correct: These are the correct and complete commands for this scenario.

2. To publish a pipeline you created, which SDK commands should you use?

  • published.pipeline = pipeline_publish(name=’training_pipeline’, 
  • description=’Model training pipeline’,
  • version=’1.0′)
  • published.pipeline = pipeline.publish(name=’training_pipeline’,
  • description=’Model training pipeline’,
  • version=’1.0′)
  • published_pipeline = pipeline.publish(name=’training_pipeline’, (CORRECT)
  • description=’Model training pipeline’,
  • version=’1.0′)
  • publishedpipeline = pipeline_publish(name=’training_pipeline’,
  • description=’Model training pipeline’,
  • version=’1.0′)

Correct: This is the correct command for publishing a pipeline using the SDK.

3. True or False?

The parameters for a pipeline have to be defined before publishing it.

  • True (CORRECT)
  • False

Correct: You must define parameters for a pipeline before publishing it.

4. After publishing a parametrized pipeline, you can pass parameter values in the JSON payload for the REST interface.

Which SDK commands can you use for this?

  • response = requests.post(rest_endpoint, (CORRECT)
  • headers=auth_header,
  • json={“ExperimentName”: “run_training_pipeline”,
  • “ParameterAssignments”: {“reg_rate”: 0.1}})response = requests_post(rest_endpoint,
  • json={“ExperimentName”: “run_training_pipeline”,
  • “ParameterAssignments”: {“reg_rate”: 0.1}})
  • response = requests.post(rest_endpoint,
  • headers()
  • json={“ExperimentName”: “run_training_pipeline”,
  • “ParameterAssignments”: {“reg_rate”: 0.1}})
  • response = requests.post(rest_endpoint,
  • json=auth_header,
  • headers={“ExperimentName”: “run_training_pipeline”,
  • “ParameterAssignments”: {“reg_rate”: 0.1}})

Correct: You must define parameters for a pipeline before publishing it.

5. You want to create a schedule for your pipeline. What object can you define for this task?

  • ScheduleSync
  • ScheduleConfig
  • ScheduleTimer
  • ScheduleRecurrence (CORRECT)

Correct: To schedule a pipeline to run at periodic intervals, you must define a ScheduleRecurrence that determines the run frequency, and use it to create a Schedule.

6. You want to configure an AKS cluster as a compute target for your service to be deployed on.

Which SDK commands do the job?

  • from azureml.core.webservice import ComputeTarget, AksWebservice
  • cluster_name = ‘aks-cluster’
  • compute_config = AksCompute.provisioning_configuration(location=’eastus’)
  • production_cluster = ComputeTarget.create(ws, cluster_name, compute_config)
  • production_cluster.wait_for_completion(show_output=True)
  • from azureml.core.compute import ComputeTarget, AksCompute
  • cluster_name = ‘aks-cluster’
  • compute_config = AksCompute.provisioning_configuration(location=’eastus’)
  • production_cluster = ComputeTarget.create(ws, cluster_name, compute_config)
  • production_cluster.wait_for_completion(show_output=True)
  • from azureml.core.webservice import ComputeTarget, AksCompute (CORRECT)
  • cluster_name = ‘aks-cluster’
  • compute_config = AksCompute.provisioning_configuration(location=’eastus’)
  • production_cluster = ComputeTarget.create(ws, cluster_name, compute_config)
  • production_cluster.wait_for_completion(show_output=True)
  • from azureml.core.compute import ComputeTarget, AksCompute
  • cluster_name = ‘aks-cluster’
  • compute_config = AksCompute.provisioning_configuration(location=’eastus’)
  • production_cluster = ComputeTarget.deploy (ws, cluster_name, compute_config)
  • production_cluster.wait_for_completion(show_output=True)

Correct: You must define parameters for a pipeline before publishing it.

7. What are the default authentication methods for ACI services and AKS services? Select all that apply.

  • Token-based for ACI services
  • Disabled for AKS services
  • Token-based for AKS services.
  • Key-based for AKS services (CORRECT)
  • Disabled for ACI services (CORRECT)

Correct: By default, authentication is set to key-based authentication for AKS services (for which primary and secondary keys are automatically generated).

Correct: By default, authentication is disabled for ACI services.

8. Which of the following statements best describes Azure Machine Learning pipelines?

  • It is a workflow of machine learning tasks in which each task is implemented as a step. (CORRECT)
  • It is a workflow of machine learning tasks in which each task is implemented as a parallel process.
  • It is a workflow of machine learning tasks in which each task is implemented as a linear sequence.

Correct: In Azure Machine learning, a pipeline is a type of workflow of machine learning tasks in which each task is implemented as a step.

CONCLUSION – Orchestrate Pipelines And Deploy Real-Time Machine Learning Services With Azure Machine Learning 

By mastering the orchestration of machine learning training with pipelines in Azure Machine Learning, you will be well-equipped to integrate DevOps practices into your workflows. This knowledge will enable you to create, publish, and run pipelines effectively, as well as register and deploy models with ease. Ultimately, this will streamline and optimize your machine learning operations, ensuring consistent and efficient training and deployment of models within a scalable and reliable framework.