COURSE 3: BUILD AND OPERATE MACHINE LEARNING SOLUTIONS WITH AZURE
Module 1: Use The Azure Machine Learning SDK To Train A Model
MICROSOFT AZURE DATA SCIENTIST ASSOCIATE (DP-100) PROFESSIONAL CERTIFICATE
Complete Coursera Study Guide
Last updated:
INTRODUCTION – Use The Azure Machine Learning SDK To Train A Model
Azure Machine Learning offers a cloud-based platform for training, deploying, and managing machine learning models. In this module, you will learn how to provision an Azure Machine Learning workspace. You will explore the various tools and interfaces available to work with Azure Machine Learning, running code-based experiments within the workspace. Finally, you will learn how to use Azure Machine Learning to train a model and register it in the workspace, ensuring a comprehensive understanding of the platform’s capabilities.
Learning Objectives
- Provision an Azure Machine Learning workspace.
- Use tools and interfaces to work with Azure Machine Learning.
- Run code-based experiments in an Azure Machine Learning workspace.
- Use a ScriptRunConfig to run a model training script as an Azure Machine Learning experiment.
- Create reusable, parameterized training scripts.
- Register trained models
PRACTICE QUIZ: KNOWLEDGE CHECK 1
1. Which are some of the assets included in a Machine Learning Workspace? Select all that apply.
- Key vault
- Data (CORRECT)
- Compute targets (CORRECT)
- Pipelines (CORRECT)
- Models (CORRECT)
- Notebooks (CORRECT)
Correct: Data that is used for experimentation and model training is included in a ML workspace.
Correct: Compute targets are used for development, training, and deployment in a ML workspace.
Correct: Pipelines that define orchestrated multi-step processes are included in a ML workspace.
Correct: Models that you have trained are included in the ML workspace.
Correct: Notebooks that contain shared code and documentation.
2. What other Azure resources can be created alongside a ML workspace?
Select all that apply.
- App Service Plan
- Virtual network
- Application Insights instance (CORRECT)
- Storage account (CORRECT)
- Key vault instance (CORRECT)
- Container registry (CORRECT)
Correct: This is used to monitor predictive services in the workspace.
Correct: Storage accounts are used to store files used by the workspace as well as data for experiments and model training.
Correct: An Azure Key Vault instance is used to manage secrets such as authentication keys and credentials used by the workspace.
Correct: A container registry is created as-needed to manage containers for deployed models.
3. True or False?
Azure Machine Learning Workspaces also support RBAC.
- True (CORRECT)
- False
Correct: You can assign role-based authorization policies to a workspace, enabling you to manage permissions that restrict what actions specific Azure Active Directory (AAD) principals can perform.
4. Which of the following Azure Machine Learning Studio tools is used as a drag and drop interface for machine learning model development without the need to code?
- Notebooks
- Designer (CORRECT)
- Automated Machine learning
Correct: The Designer tool is a drag and drop interface for “no code” machine learning model development.
5. For which development languages does Azure Machine Learning provide software development kits (SDK)? Choose all that apply.
- Ruby
- Java
- R (CORRECT)
- Python (CORRECT)
Correct: Azure Machine Learning provides software development kits (SDKs) for R.
Correct: Azure Machine Learning provides software development kits (SDKs) for Python.
PRACTICE QUIZ: KNOWLEDGE CHECK 2
1. When using a script-based experiment to train a model, what is the purpose of the following commands in the script?
diabetes = pd.read_csv(‘data.csv’)
X, y = diabetes[[‘Feature1′,’Feature2′,’Feature3’]].values, diabetes[‘Label’].values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.30)
- Calculate accuracy
- Prepare the dataset (CORRECT)
- Training a logistic regression model
- Save the trained model
Correct: These commands prepare the dataset.
2. When using a script-based experiment to train a model, what is the purpose of the following commands in the script?
os.makedirs(‘outputs’, exist_ok=True)
joblib.dump(value=model, filename=’outputs/model.pkl’)
- Save the trained model (CORRECT)
- Prepare the dataset
- Train a logistic regression model
- Calculate accuracy
Correct: These commands save the trained model in the outputs folder using the joblib package.
3. In order to run the script as an experiment, you have to create a ScriptRunConfig file.
What is the purpose of the following commands?
packages = CondaDependencies.create(conda_packages=[‘scikit-learn’,’pip’],
pip_packages=[‘azureml-defaults’])
sklearn_env.python.conda_dependencies = packages
- Submit the experiment
- Ensure the required packages are installed (CORRECT)
- Create a Python environment for the experiment
- Create a script config
Correct: In this example, the script uses Scikit-Learn so you must create an environment that includes that.
4. Which of the below libraries is used to read the arguments passed to the script?
- pandas
- numpy
- argparse (CORRECT)
- joblib
Correct: To use parameters in a script, you must use a library such as argparse to read the arguments passed to the script and assign them to variables.
5. What happens when you register a model with the same name as an existing model?
- You cannot save a new model with the name of an existing model.
- It creates a new version of the model. (CORRECT)
- It prompts for confirmation and overwrites the previous model if accepted.
Correct: Registering a model with the same name as an existing model automatically creates a new version of the model, starting with 1 and increasing in units of 1.
QUIZ: START PREP
1. You installed the Azure Machine Learning Python SDK and you want to use it to create a workspace named “aml-workspace” on your subscription.
How do you code this in Python?
- azureml.core import Workspace
- ws = Workspace.create(name=’aml-workspace’,
- subscription_id=’123456-abc-123…’,
- resource_group=’aml-resources’,
- create_resource_group=False,
- location=’eastus’
- )
- from azureml.core import Workspace
- ws = Workspace.create(name=’aml-workspace’,
- subscription_id=’123456-abc-123…’,
- resource_group=’aml-resources’,
- location=’eastus’
- )
- from azureml.core import Workspace (CORRECT)
- ws = Workspace.create(name=’aml-workspace’,
- subscription_id=’123456-abc-123…’,
- resource_group=’aml-resources’,
- create_resource_group=True,
- location=’eastus’
- )
Correct: This is the correct and complete command to run for this scenario.
2. You installed the Azure Machine Learning CLI extension and you want to use it to create an ML workspace in an existing resource group.
Which Azure CLI command does this?
- az ml workspace create -w ‘aml-workspace’ -g ‘aml-resources’ (CORRECT)
- az ml ws create -w ‘aml-workspace’ -g ‘aml-resources’
- new az ml workspace create -w ‘aml-workspace’ -g ‘aml-resources’
- az ml new workspace create -w ‘aml-workspace’ -g ‘aml-resources’
Correct: This is complete statement to the resources workspace.
3. Which of the following package managers and CLI commands can you use to install the Azure Machine Learning SDK for Python?
- nuget azureml-sdk
- yarn install azureml-sdk
- pip install azureml-sdk (CORRECT)
- npm install azureml-sdk
Correct: This package management system contains the Python Azure ML SDK and is the CLI command to install it.
4. If you want to connect to your Azure ML workspace using a configuration file, which Python command can you use?
- from azureml.core import Workspace
- ws = Workspace.from.config
- from azureml.core import Workspace
- ws = from.config_Workspace()
- from azureml.core import Workspace
- ws = Workspace.from_config() (CORRECT)
- Correct: This is the correct command for this task.
5. After an experiment run has been completed, what run object method can you use to list the generated files?
- download_files
- get_file_names (CORRECT)
- list_file_names
- download_file
Correct: You can use the run objects get_file_names method to list the files generated. Standard practice is for scripts that train models to save them in the run’s outputs folder.
6. After you run an experiment to train a model, you want to store the model in the Azure ML workspace, so it can be available to other experiments and services.
How can you do this?
- Save the experiment script as a notebook
- Save the model as a file in a Key Vault instance
- Save the model as a file in a compute instance
- Register the model in the workspace (CORRECT)
Correct: To store a model in the workspace, you have to register it.
7. If you want to view the models you registered in Azure ML studio using the Model object, which Python command can you use?
- from azureml.core import Model (CORRECT)
- for model in Model.list(ws):
- print(model.name, ‘version:’, model.version)
- from azureml.core import Model
- for model in List.Model(ws):
- print(model.name, ‘version:’, model.version)
- from azureml.core import Model
- for model in Model.object(ws):
- print(model.name, ‘version:’, model.version)
- from azureml.core import Model
- for model in Model.list(ws):
- get(model.name, ‘version:’, model.version)
Correct: This is the correct command for this request.
8. What are some of the Azure resources created alongside a workspace? Check all that apply.
- A Development environment
- A container registry (CORRECT)
- A storage account (CORRECT)
Correct: This is created as needed to manage containers for deployed models.
Correct: This is used to store files used by the workspace as well as data for experiments and model training.
9. Which of the following is an example of a user interface for managing an Azure Machine Learning workspace.
- The Azure Machine Learning SDK
- Azure Machine Learning Studio (CORRECT)
- Visual Studio Code
Correct: Azure Machine Learning Studio is an example of a user interface for managing an Azure Machine Learning workspace.
10. True or false?
To access the experiment run context (which is needed to log metrics) the script must import the azureml.core.Run class and call its get_context method.
- True (CORRECT)
- False
Correct: To access an experiment run context the script must import the azureml.core.Run class and call its get_context method.
CONCLUSION – Use The Azure Machine Learning SDK To Train A Model
In conclusion, Azure Machine Learning provides a robust cloud-based platform for training, deploying, and managing machine learning models. Throughout this module, you have learned how to provision an Azure Machine Learning workspace and utilize the platform’s tools and interfaces for running code-based experiments. By the end, you have gained the knowledge to train a model and register it within the workspace. With these skills, you are now well-equipped to leverage Azure Machine Learning for your machine learning projects, enabling efficient model development and deployment.
Quiztudy Top Courses
Popular in Coursera
- Google Advanced Data Analytics
- Google Cybersecurity Professional Certificate
- Meta Marketing Analytics Professional Certificate
- Google Digital Marketing & E-commerce Professional Certificate
- Google UX Design Professional Certificate
- Meta Social Media Marketing Professional Certificate
- Google Project Management Professional Certificate
- Meta Front-End Developer Professional Certificate
Liking our content? Then, don’t forget to ad us to your BOOKMARKS so you can find us easily!

