Starting with the Azure ML service

To start using the Azure ML service, we can either create a workspace programmatically or by using Azure portal.

If we want to use the Azure portal (which can be found at the following link: https://portal.azure.com), follow these steps:

  1. First, search for machine learning on the Azure portal
  2. We then need to provide a name for the workspace, which in our case will be iiot-book-ml-workspace
  1. Choose the standard resource group, iiot-book-res, and then click on the Create button, as shown in the following screenshot:

Azure ML instantiation

After that, we can access the Azure Notebook by clicking on the Experiments tab in the workspace that we just created, then clicking on Open Azure Notebooks, as shown in the following screenshot:

Azure Notebook

Note that when we create a workspace, Azure instantiates additional services, as indicated by the dashed rectangle in the preceding screenshot.

To create a workspace programmatically, follow these steps:

  1. From the command line, then install the Jupyter Notebook and the Azure ML SDK:
$ pip install azureml-sdk[notebooks]
$ pip install jupyter
  1. Then, we can start our Jupyter Notebook. From the command line, run the following command:
$ jupyter notebook
  1. We need to create a new notebook with the following code:
import azureml.core
print(azureml.core.VERSION)

from azureml.core import Workspace

ws = Workspace.create(name='iiot-book-ml-workspace',
subscription_id='<subscription-id>',
resource_group='iiot-book-res',
create_resource_group=True,
location='eastus2'
)
# store information on the configuration file
ws.write_config()

# see the details
ws.get_details()

# write here your experiment
# …
# clean the workspace
ws.delete(delete_dependent_resources=True)

To get the subscription ID, we can search for it on the Azure portal, as shown in the following screenshot:

How to locate the subscription ID from the Azure portal

Instead of creating the workspace every time, we can save the configuration in a config.json file and restore it with the following Python code:

ws = Workspace.from_config()
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset