Setting up your Visual Studio Code Tools for AI

Philip Roimon Domingo
Towards Data Science
6 min readOct 3, 2017

--

Microsoft just launched a new set of tools related to Artificial Intelligence last September at Microsoft Ignite 2017, and one of those tools is Visual Studio Code Tools for AI.

Visual Studio Code Tools for AI is an extension to build, test, and deploy Deep Learning / AI solutions. It seamlessly integrates with Azure Machine Learning for robust experimentation capabilities, including but not limited to submitting data preparation and model training jobs transparently to different compute targets.

This is actually a useful tool for developers who needs to work on a AI Solution, while still using the code editor of their choice, which in my case is Visual Studio Code.

Getting Started

Before we actually proceed with installing and setting up the extension in VS Code, we will first need to create an Azure Machine Learning Experimentation account and Azure Machine Learning Model Management account, which will allow us to create a project using sample explorer in VS Code later on.

Log in to Azure Portal

First step is to login your Azure account at portal.azure.com. If you don’t have an Azure account, you can go here to get a free trial.

Create an Azure Machine Learning Experimentation and Model Management account

Once you’re in the Azure portal, do the following:

  1. Click the “+ New” button
  2. Search for “Machine Learning Experimentation”

3. Click “Create”

4. Fill out the Machine Learning Experimentation information

5. Click “Create” and you should be able to see that the services is successfully created

Things to keep in mind:

  1. Make sure that you check the “Create Model Management account” if you still don’t have any.
  2. “Number of seats” is basically the total number of Azure users you can add to your Experimentation account.
  3. A subscription can have only one plan with a “DevTest” pricing tier.
  4. Currently supported location is Australia East, East US 2, and West Central US.

Install Azure Machine Learning Workbench

Once we have our Azure Machine Learning Experimentation and Model Management account setup, next thing we’re going to do is to install Azure Machine Learning Workbench.

Azure Machine Learning Workbench is a desktop application plus command-line tools, supported on both Windows and macOS. It allows you to manage machine learning solutions through the entire data science life cycle.

Currently the Azure Machine Learning Workbench desktop app can be installed on the following operating systems only:

  • Windows 10
  • Windows Server 2016
  • macOS Sierra (macOS High Sierra is not supported yet)

Note: Azure Machine Learning Workbench will also download and install other dependent components such as Python, Miniconda, Azure CLI, and etc.

To install the AML Workbench, you can click the recently created Machine Learning Experimentation service and you should be able to see this:

Then you can just click the specific OS that you’re using to download the installer to your machine.

Note: For macOS, before you install the AmlWorkbench Setup file, you will first need to install openssl library using Homebrew.

$ brew install openssl
$ mkdir -p /usr/local/lib
$ ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
$ ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/

Install and explore project samples in Visual Studio Code Tools for AI

Now that we have our Azure Machine Learning accounts and Azure Machine Learning Workbench setup, we’re now ready to use Visual Studio Code Tools for AI

  1. Download the Visual Studio Code for AI extension here or you can just search it on the extensions within VS Code.
  2. Once installed, restart VS Code
  3. Open command palette (CTRL + SHIFT + P in Windows or COMMAND-P in macOS)
  4. Type “>AI: Azure ML — Login” and this will show you a message in terminal to open your browser and enter the code provided

5. Once you’ve successfully login your account, open command palette again and type “>AI: Open Azure ML Sample Explorer”

Note: Sometimes when you enter the “AI: Open Azure ML Sample Explorer” command, nothing is happening in VS Code, and when you try to enter the command again, the command will not show in the command palette. To fix this, just restart the VS Code and you should be able to see the command again.

Create a new project in Azure Machine Learning Sample Explorer

We’ll now then try to create a simple project using sample explorer and test it in our local machine.

  1. Click “install” to the Simple Linear Regression project
  2. Enter the project name
  3. Enter the project installation folder
  4. Enter the account and workspace we’ve just created earlier using Azure
  5. Once the project is successfully created, you’ll be able to see this files:

6. You can check the readme.md file as well to know the packages required to install to properly run the project. In this case, we have to install matplotlib.

# For macOS
$ pip3 install matplotlib
# For Windows
$ conda install matplotlib

Submit a job and train the model locally

Once we have matplotlib package installed, we will now submit a job to train the model locally.

  1. You can right click the linear_reg.py file and click the “AI: Submit Job”

2. Alternatively, you can open the linear_reg.py again and open the command palette and type “AI: Submit Job”

3. Make sure to select “local” as your configuration

4. Submit the job and you should be able to see the output in the terminal

So what do you think about Visual Studio Code Tools for AI? Personally, when submitting a job or preparing the data that will be used for training the model, I prefer using Azure Machine Learning Workbench as it has better visualization to what’s happening to the job. Here’s what will look like when you run the job in AML Workbench:

If you want to know more about Visual Studio Code Tool for AI, you can check their GitHub repository here and if you’re also interested in AML Workbench, you can check their documentation here as well.

--

--

Software Engineer / Speaker / Passionate in AI, IoT and AR / Soon-to-be-Entrepreneur