Qcon Code Lab: AI for R Users



README.md

David M Smith (@revodavid), Developer Advocate at Microsoft

Last updated: April 9, 2018 Clone this library to get the latest updates

This self-guided workshop provides R scripts to demonstrate various AI techniques using the Microsoft Cognitive Services APIs in Azure. The scripts are provided as Jupyter Notebooks within the Azure Notebooks service. You don't need a Microsoft Account to view the scripts, but you will need to set one up and generate keys in Azure to run the examples. All of the examples use free Azure services.

If you're new to Notebooks, check out the Jupyter Notebook documentation.

If you're new to R, you might want to start with this Introduction to R notebook to get a sense of the language.

You will need:

  1. A Microsoft account. You can use an existing Outlook 365 or Xbox Live account, or create a new one.

  2. A Microsoft Azure subscription. If you don't already have an Azure subscription, you can visit https://cda.ms/kT and also get $200 in credits to use with paid services. You'll need to provide a credit or debit card, but everything we'll be doing is free to use. If you're a student, you can also register at https://cda.ms/kY without a credit card for a $100 credit.

You'll also need a few other things specific to this workshop. Follow the instructions below to set up everything you need.

  1. Visit https://portal.azure.com
  2. Sign in with your Microsoft Account. If you don't have a Microsoft account, use the links above to create one for free.

In Azure, a Resource Group is a collection of services you have created. It groups services together, and makes it easy to bulk-delete things later on. We'll create one for this lab.

  1. Visit https://portal.azure.com (and sign in if needed)
  2. Click "Resource Groups" in the left column
  3. Click "+ Add"
    • Resource Group Name: qcon
    • Subscription: there should be just one option
    • Resource Group Location: East US
  4. Click "Create"

A notification will appear in the top right. Click the button "Pin to Dashboard" to pin this resource group to your home page in the Azure portal, as you'll be referring to it frequently.

  1. Visit https://portal.azure.com (and sign in if needed)
  2. Click "+ Create a Resource" (top-left corner)
  3. Click "AI + Cognitive Services"
  4. Click "Computer Vision API"
    • Name: qcon-vision
    • Subscription: there should be just one option
    • Location: East US
    • Pricing Tier: F0 (free, 20 calls per minute)
    • Resource Group: Use existing "qcon" group
  5. Click "Create""
  1. Visit https://portal.azure.com (and sign in if needed)
  2. Click "+ Create a Resource" (top-left corner)
  3. With the "Search the Marketplace" box, search for "Custom Vision Service"
  4. Select "Custom Vision Service (preview)" and click "Create"
    • Name: qcon-customvision
    • Subscription: there should be just one option
    • Location: South Central US
    • Prediction Pricing Tier: F0 (free, 2 transactions per second)
    • Training pricing Tier: F0 (2 projects)
    • Resource Group: Use existing "qcon" group
  5. Click "Create"
  1. Visit https://notebooks.azure.com/davidsmi/libraries/qcon
    • Sign in with your Microsoft account if needed
  2. click Clone in the toolbar, to create a copy of the workshop materials

Download the file and provide the keys listed from the Azure Portal.

(To download this file, highlight it in the Library view and then press or click the download icon in the toolbar.)

For the first line of the file, , change it to . For the remaining keys, visit your resource group in the Azure Portal and then:

  1. Click on the API resource for Computer Vision

  2. In the menu, click on "keys"

  3. Click the "copy to clipboard" next to KEY 1. (You can ignore KEY 2).

  4. Paste the key into the entry in keys.txt

  5. Click on the API resource for Custom Vision

  6. In the menu, click on "keys"

  7. Click the "copy to clipboard" next to KEY 1. (You can ignore KEY 2).

  8. Paste the key into the entry in keys.txt

  9. Click on the API resource for Custom Vision (this resource was created automatically for you).

  10. In the menu, click on "keys"

  11. Click the "copy to clipboard" next to KEY 1. (You can ignore KEY 2).

  12. Paste the key into the entry in keys.txt

Your final file will look like this, but with different (working) keys:

Once you've done this for all the cognitive services, save the file and upload it to replace the existing file in Azure Notebooks. To upload the modified file, go to the Library and press the "+" (New File) icon or press , click "From Computer" > "Choose Files" and select the file on your hard drive, and click "Upload". A box saying "File Exists, Overwrite?" will appear; click it to continue.

The R scripts are provided as Jupyter Notebook files (with the extension). You can tackle the files in any order, but we recommend the following sequence:

  1. : Explore analyzing images from Wikimedia Commons using the Microsoft Vision API
  2. : Create the "Not Hotdog" image recognition application featured in Silicon Valley

For more examples of using the Cognitive Services APIs from R, take a look a the following blog posts. R code is included in the posts or in linked Github repositories.

If you get stuck or just have other questions, you can contact me here:

David Smith

Clones Terminal Edit
Showing 8 notebooks