Run Experiments

Experiments are at the core of a data scientist’s work. In Azure Machine Learning, an experiment is used to run a script or a pipeline, and usually generates outputs and records metrics. In this exercise, you will use the Azure Machine Learning SDK to run Python code as experiments.

Before You start

If you have not already done so, complete the Create an Azure Machine Learning Workspace exercise to create an Azure Machine Learning workspace and compute instance, and clone the notebooks required for this exercise.

Open Jupyter

While you can use the Notebooks page in Azure Machine Learning studio to run notebooks, it’s often more productive to use a more fully-featured notebook development environment like Jupyter. Fortunately, your Azure Machine Learning compute instance includes an installation of Jupyter.

Tip: Jupyter Notebook is a commonly used open source tool for data science. You can refer to the documentation if you are unfamiliar with it.

  1. In Azure Machine Learning studio, view the Compute page for your workspace; and on the Compute Instances tab, start your compute instance if it is not already running.
  2. When the compute instance is running, click the Jupyter link to open the Jupyter home page in a new browser tab. Be sure to open Jupyter and not JupyterLab.

Tip: New to Python? Use the Python cheat sheet to understand the code.

Verify the Azure Machine Learning SDK is Installed

The Azure Machine Learning SDK is installed by default on your compute instance. Follow these steps to verify the installation.

  1. In the Jupyter notebook environment, create a new Terminal. This will open a new tab with a command shell.
  2. Enter the following command to verify that the Azure ML SDK is installed:

     pip show azureml-sdk
    

    Note the version of the SDK package installed.

  3. The azureml-sdk SDK package provides the most important libraries needed to work with Azure Machine Learning> However, there are some additional packages that contain other useful libraries not included in the main SDK package. Use the following command to verify that the azureml-widgets package, which contains libraries for displaying Azure Machine Learning information in notebooks, is also installed:

     pip show azureml-widgets
    
  4. Close the Terminal tab and return to the tab containing the Jupyter home page.

More Information: For more details about installing the Azure ML SDK and its optional components, see the Azure ML SDK Documentation.

Run experiments in a notebook

Experiments in Azure Machine Learning need to be initiated from some sort of control layer; often a script or program. In this exercise, you’ll use a notebook to control experiments.

  1. In the Jupyter home page, browse to the /users/your-user-name/mslearn-dp100 folder where you cloned the notebook repository, and open the Run Experiments notebook.
  2. Then read the notes in the notebook, running each code cell in turn.
  3. When you have finished running the code in the notebook, on the File menu, click Close and Halt to close it and shut down its Python kernel. Then close all Jupyter browser tabs.

Clean-up

If you’re finished working with Azure Machine Learning for now, in Azure Machine Learning studio, on the Compute page, on the Compute Instances tab, select your compute instance and click Stop to shut it down. Otherwise, leave it running for the next lab.

Note: Stopping your compute ensures your subscription won’t be charged for compute resources. You will however be charged a small amount for data storage as long as the Azure Machine Learning workspace exists in your subscription. If you have finished exploring Azure Machine Learning, you can delete the Azure Machine Learning workspace and associated resources. However, if you plan to complete any other labs in this series, you will need to repeat the Create an Azure Machine Learning Workspace exercise to create the workspace and prepare the environment first.