Tutorial: Get started creating your first ML experiment with the Python SDK

APPLIES TO: yesBasic edition yesEnterprise edition                    (Upgrade to Enterprise edition)

In this tutorial, you complete the end-to-end steps to get started with the Azure Machine Learning Python SDK running in Jupyter notebooks. This tutorial is part one of a two-part tutorial series, and covers Python environment setup and configuration, as well as creating a workspace to manage your experiments and machine learning models. Part two builds on this to train multiple machine learning models and introduce the model management process using both Azure Machine Learning studio and the SDK.

In this tutorial, you:

  • Create an Azure Machine Learning Workspace to use in the next tutorial.
  • Clone the tutorials notebook to your folder in the workspace.
  • Create a cloud-based compute instance with Azure Machine Learning Python SDK installed and pre-configured.

If you don’t have an Azure subscription, create a free account before you begin. Try the free or paid version of Azure Machine Learning today.

Create a workspace

An Azure Machine Learning workspace is a foundational resource in the cloud that you use to experiment, train, and deploy machine learning models. It ties your Azure subscription and resource group to an easily consumed object in the service.

You create a workspace via the Azure portal, a web-based console for managing your Azure resources.

  1. Sign in to Azure portal by using the credentials for your Azure subscription.

  2. In the upper-left corner of Azure portal, select + Create a resource.

    Create a new resource

  3. Use the search bar to find Machine Learning.

  4. Select Machine Learning.

  5. In the Machine Learning pane, select Create to begin.

  6. Provide the following information to configure your new workspace:

    Field Description
    Workspace name Enter a unique name that identifies your workspace. In this example, we use docs-ws. Names must be unique across the resource group. Use a name that's easy to recall and to differentiate from workspaces created by others.
    Subscription Select the Azure subscription that you want to use.
    Resource group Use an existing resource group in your subscription or enter a name to create a new resource group. A resource group holds related resources for an Azure solution. In this example, we use docs-aml.
    Location Select the location closest to your users and the data resources to create your workspace.
    Workspace edition Select Basic as the workspace type for this tutorial. The workspace type (Basic & Enterprise) determines the features to which you’ll have access and pricing. Everything in this tutorial can be performed with either a Basic or Enterprise workspace.
  7. After you are finished configuring the workspace, select Review + Create.


    It can take several minutes to create your workspace in the cloud.

    When the process is finished, a deployment success message appears.

  8. To view the new workspace, select Go to resource.


Take note of your workspace and subscription. You'll need these to ensure you create your experiment in the right place.

Run notebook in your workspace

This tutorial uses the cloud notebook server in your workspace for an install-free and pre-configured experience. Use your own environment if you prefer to have control over your environment, packages and dependencies.

Follow along with this video or use the detailed steps below to clone and run the tutorial from your workspace.

Clone a notebook folder

You complete the following experiment set-up and run steps in Azure Machine Learning studio, a consolidated interface that includes machine learning tools to perform data science scenarios for data science practitioners of all skill levels.

  1. Sign in to Azure Machine Learning studio.

  2. Select your subscription and the workspace you created.

  3. Select Notebooks on the left.

  4. Select the Samples tab at the top.

  5. Open the Python folder.

  6. Open the folder with a version number on it. This number represents the current release for the Python SDK.

  7. Select the "..." at the right of the tutorials folder and then select Clone.

    Clone tutorials folder

  8. A list of folders displays showing each user who accesses the workspace. Select your folder to clone the tutorials folder there.

Open the cloned notebook

  1. Open the tutorials folder that was just closed into your User files section.


    You can view notebooks in the samples folder but you cannot run a notebook from there. In order to run a notebook, make sure you open the cloned version of the notebook in the User Files section.

  2. Select the tutorial-1st-experiment-sdk-train.ipynb file in your tutorials/create-first-ml-experiment folder.

    Open tutorials folder

  3. On the top bar, select a compute instance to use to run the notebook. These VMs are pre-configured with everything you need to run Azure Machine Learning.

  4. If no VMs are found, select + Add to create the compute instance VM.

    1. When you create a VM, follow these rules:

      • Name is required and can't be empty.
      • Name needs to be unique (in a case insensitive fashion) across all existing compute instances in the Azure region of the workspace/compute instance. You'll get an alert if the name you choose is not unique.
      • Valid characters are upper and lower case letters, numbers (0 to 9), and dash character (-).
      • Name must be between 3 and 24 characters long.
      • Name should start with a letter (not a number or a dash character).
      • If dash character is used, then it needs to be followed by at least one letter after the dash. Example: Test-, test-0, test-01 are invalid, while test-a0, test-0a are valid instances.
    2. Select the Virtual Machine size from the available choices.

    3. Then select Create. It can take approximately 5 minutes to set up your VM.

  5. Once the VM is available it will be displayed in the top toolbar. You can now run the notebook either by using Run all in the toolbar, or by using Shift+Enter in the code cells of the notebook.

If you have custom widgets or prefer using Jupyter/JupyterLab select the Jupyter drop down on the far right, then select Jupyter or JupyterLab. The new browser window will be opened.

Next steps

In this tutorial, you completed these tasks:

  • Created an Azure Machine Learning workspace.
  • Created and configured a cloud notebook server in your workspace.

In part two of the tutorial you run the code in tutorial-1st-experiment-sdk-train.ipynb to train a machine learning model.


If you do not plan on following part 2 of this tutorial or any other tutorials, you should stop the cloud notebook server VM when you are not using it to reduce cost.