In this lab you use Machine Learning APIs from within Datalab.

What you learn

In this lab, you learn how to invoke ML APIs from Python and use their results.

What you need

You must have completed Lab 0 and have the following:

In this lab, you will first

and then invoke ML APIs from Datalab to carry out some representative tasks:

ML APIs are microservices. When we build ML models ourselves, it should be our goal to make them so easy to use and stand-alone.

Step 1

Go back into your Cloud Datalab tab.

Step 2

In Cloud Datalab home page (browser), navigate into "notebooks" and add a new notebook using the icon on the top left.

Step 3

Rename this notebook as ‘recheckout'.

Step 4

In the new notebook, enter the following commands in the cell, and click on Run (on the top navigation bar) to run the commands:

%bash
gcloud source repos clone asl-ml-immersion --project=asl-ml-immersion
rm -rf asl-ml-immersion/.git

Step 5

Confirm that you have cloned the repo by going back to Datalab browser, and ensure you see the asl-ml-immersion directory. All the skeleton files for all labs throughout this course are available in this directory.

Step 6

In Datalab, click on the "Ungit" icon in the Datalab toolbar. Commit all your changes, including the files that you have pulled down. After commit, select master and click on Push.

Step 7

To confirm that the cloned repo files have been saved into your project's source repositories, go into GCP console and using the menu, navigate to Source Repositories > Repositories. Next, click on "datalab-repositories" and verify that you have the asl-ml-immersion directory with code files in it.

To get an API key:

Step 1

From the GCP console menu, select APIs and services and select Library

Step 2

In the search box, type vision to find the Google Cloud Vision API and click on the hyperlink.

Step 3

Click Enable if necessary

Step 4

Follow the same process to enable Translate API, Speech API, and Natural Language APIs.

Step 5

From the GCP console menu, select APIs and services and select Credentials.

Step 6

If you do not already have an API key, click the Create credentials button and select API key. Once created, click close. You will need this API key in the notebook later.

Step 1

In the Datalab browser, navigate to asl-ml-immersion > 1.2_googleml_soln > mlapis.ipynb

Step 2

Read the commentary, then run the Python snippets (Use Shift+Enter to run each piece of code) in the cell, step by step. Make sure to insert your API Key in the first Python cell.

©Google, Inc. or its affiliates. All rights reserved. Do not distribute.