Download as pdf or txt
Download as pdf or txt
You are on page 1of 78

Cut Video

Course 1: How Google Does ML

Module 5: Python notebooks in the cloud

Lesson Title: Module Introduction

Format: Talking head with slides


© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Python notebooks in the cloud
How Google does ML

Machine Learning on Google Cloud Platform

© 2017 Google Inc. All rights reserved. Google


and the Google logo are trademarks of Google Inc.
All other company and product names may be
trademarks of the respective companies with
which they are associated.
© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Module Learning Objectives
● Carry out data science tasks in notebooks
● Rehost notebooks on the cloud
● Execute ad-hoc queries at scale
● Invoke pre-trained ML models from Datalab

Python
Intro to What it means to Human-centered
How Google does ML notebooks in
Specialization be AI-first ML
the Cloud

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Agenda
Cloud Datalab

Compute Engine and Cloud Storage

Data Analysis with BigQuery

Machine Learning APIs

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cut Video

Course 1: How Google Does ML

Module 5: Python notebooks in the cloud

Lesson Title: Cloud Datalab

Format: Camtasia screenrecording + demo


© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Increasingly, data analysis and machine learning are carried
out in self-descriptive, shareable, executable notebooks

Share
Code

A typical
notebook
Output contains code,
charts, and
explanations

Markup Image Source:


Git Logo from Wikipedia

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Demo of Cloud Datalab

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cut Video

Course 1: How Google Does ML

Module 5: Python notebooks in the cloud

Lesson Title: Development process

Format: Camtasia screenrecording + demo


© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Datalab notebooks are developed in an iterative, collaborative
process

PHASE 5 PHASE 1
5 2 5
Share and Write code in
collaborate Python
1
Development

PHASE 4
Process in
Cloud Datalab PHASE 2
3
Write Run cell
commentary (Shift+Enter)
in markdown
4
PHASE 3

Examine Output

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Datalab notebooks let you change the underlying hardware

Notebook server Hosted on


Cloud Datalab Compute Engine
Developer
Laptop

Save/read 10 GB PD
CUS
VM
4 2 1
Notebook files
Cloud repository

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Demo of rehosting Cloud Datalab

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cut Video

Course 1: How Google Does ML

Module 5: Python notebooks in the cloud

Lesson Title: Working with managed services

Format: Camtasia screenrecording


© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
You can develop locally with Datalab and then scale out data
processing to the cloud

Cloud Pandas
CSV Files improve
Datalab Dataframes
Apache Tensor
Beam Flow

improve /
serverless /
hypertune
Cloud Cloud Cloud
Storage Dataflow Machine
Learning

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Datalab integrates well with Google Cloud Platform products

Exploring and Analyzing BigQuery, Google Cloud Storage

Machine Learning and Modeling TensorFlow and GCML

Visualizing Google Charts or Plotly or matplotlib

Seamless product combination CMLE, Dataflow, CloudStorage

Integration authentication and code source control

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Starting Cloud Datalab in Cloud Shell is quite simple ...

1
datalab create my-datalab-vm \
--machine-type n1-highmem-8 \
--zone us-central1-a
2

What happens to your work


when you are through? You do
want to stop paying for the
3 datalab machine ...
© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cut Video

Course 1: How Google Does ML

Module 5: Python notebooks in the cloud

Lesson Title: Compute and storage

Format: Camtasia screenrecording


© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Agenda
Cloud Datalab

Compute Engine and Cloud Storage

Data Analysis with BigQuery

Machine Learning APIs

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
21

Google Cloud provides an earth-scale computer

Networking

Data storage

Compute power

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
22

Compute Engine provides customizable machine types and


flexible compute options

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
23

Cloud Storage is durable, persistent and organized in buckets

Google Cloud Platform Project

Bucket Bucket
Copy

Objects Objects
Data and Data and
metadata metadata

gsutil cp sales*.csv gs://acme-sales/data/

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
24

Control latency and availability with zones and regions


Choose the closest
Distribute your apps and
zone/region so as to
data across zones to
to reduce latency.
reduce service disruptions.

Region: North America Region: Europe Region: ...


Zone: us-central1-a Zone: europe-west1-b Zone: ...
... ... ...

Distribute your apps and data across


regions for global availability.
© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cut Video

Set up Qwiklabs

NOTE TO VID EDITOR:


Lak intro lab

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Lab environment

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Use Qwiklabs to get a temporary GCP account

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Come back to Qwiklabs to practice; do our Quests

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Source code for labs is on GitHub

https://github.com/GoogleCloudPlatform/training-dat
a-analyst/tree/master/courses/machine_learning/dee
pdive

Later, practice taking the lab apart and trying to build it


yourself on your own GCP account (strongly
recommended)

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cut Video

Lab: Rent-a-VM

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Lab: Rent-a-VM to process
earthquakes data

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Lab: Rent-a-VM to process earthquakes data

In this lab you spin up a virtual 1. Create a Compute 2. SSH into the instance
machine, configure its security, Engine instance with the Install the software
access it remotely, and then necessary Access and package Git (for source
carry out the steps of an Security code version control)
ingest-transform-and-publish
data pipeline manually.

3. Ingest data into a 4. Store the transformed


instance and then data on Cloud Storage;
transform it Publish data to the web

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cut Video

Lab debrief

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cut Video

CloudShell

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Follow-along: Cloud Shell gives you an easy command-line

Cli
ck
Do
Now

● Pre-installed with the tools, libraries, and so on you need to interact


with Google Cloud Platform (including a code editor)

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cut Video

3rd wave of cloud

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Agenda
Cloud Datalab

Compute Engine and Cloud Storage

Data Analysis with BigQuery

Machine Learning APIs

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Spinning up VMs yourself doesn’t scale … what you want are
managed services that autoscale for you
2002 2004 2005 2006 2008 2010 2012 2014 2015 2017

Google Papers

GFS MapReduce BigTable Dremel PubSub Flume Java Millwheel Dataflow TensorFlow Spanner
Megastore

Cloud Dataproc
BigQuery Pub/Sub Cloud Spanner
Cloud Dataflow

Google Big Data Stack 1.0 Google Big Data Stack 2.0
© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Demo: Query large datasets within
BigQuery

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Demo: Query large datasets in seconds
#standardsql

# medicare claims in 2014


SELECT
nppes_provider_state AS state,
ROUND(SUM(total_claim_count) / 1e6) AS total_claim_count_millions
FROM
`bigquery-public-data.medicare.part_d_prescriber_2014`
GROUP BY
state
ORDER BY
total_claim_count_millions DESC
LIMIT 5;

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
BigQuery offers...

Interactive analysis of petabyte scale databases


1

Familiar, SQL 2011 query language and functions


2

Many ways to ingest, transform, load, export data to/from BigQuery


3

Inexpensive data storage; queries charged on amount of data processed


4

Integration with Datalab for your data analysis needs


5

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cut Video

Lab: Datalab and BigQuery

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Lab: Analyzing data using
BigQuery and Datalab

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Lab: Analyzing data Using Datalab and BigQuery

In this lab, you analyze a large 1. Launch Cloud Datalab

dataset using Google


BigQuery and Cloud Datalab.

2. Invoke a BigQuery query


(70 million rows; 8 GB)

3. Create graphs in Datalab

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Notes to Video Editor:
Cut Video: ML, not rules
Insert: Lak talking head intro Sara

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Agenda
Cloud Datalab

Compute Engine and Cloud Storage

Data Analysis with BigQuery

Machine Learning APIs

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
How would we do this without ML?

CC-BY-SA 2.0 Wikimedia Commons


https://commons.wikimedia.org/wiki/File:Apple_in_lightbox.png

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
How would we do this without ML?

CC-BY-SA 2.0 Wikimedia Commons


https://commons.wikimedia.org/wiki/File:Apple_in_lightbox.png

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
How would we do this without ML?

CC-BY-SA 2.0 Wikimedia Commons


https://commons.wikimedia.org/wiki/File:Apple_in_lightbox.png
What about a dog... and a mop? Easy, right?

CC-BY 4.0 Wikimedia Commons https://commons.wikimedia.org/wiki/File:Mop_and_bucket.jpg

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Not so fast...

CC-BY-SA-2.5 Wikimedia Commons https://commons.wikimedia.org/wiki/File:Komondor_Westminster_Dog_Show_crop.jpg


CC-BY-2.0 Wikimedia Commons https://commons.wikimedia.org/wiki/File:2014_Westminster_Kennel_Club_Dog_Show_(12487315865).jpg
CC-BY-2.0 Petful https://www.flickr.com/photos/petsadviser-pix/16395099127
CC-BY-SA-2.0 Jeffrey Beall https://www.flickr.com/photos/denverjeffrey/6903790333

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Two ways to add ML to your apps rning
Friendly machine lea

Custom ML models

Vision API Speech API Translation


API
TensorFlow Machine Learning
Engine

Natural Video
Language API Intelligence API

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cut Video

Cloud Vision API

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cloud Vision
Complex image detection with a
simple REST request
GIPHY: Cloud Vision in production

http://engineering.giphy.com

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Label & web Logo
OCR
detection detection

Landmark Crop Explicit content


detection hints detection

Confidential & Proprietary


© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
You can try out the ML APIs in your browser

cloud.google.com/vision
© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Vision API demo

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cut Video

Video Intelligence API

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cloud Video
Intelligence
Understand your video’s entities
at shot, frame, or video level

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Video &
Label Shot change
scene-level
detection detection
annotations

Explicit content
Regionalization
detection

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Video API demo

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cut Video

Cloud Speech API

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cloud Speech
Speech to text transcription in
100+ languages
Batch &
Speech to text Speech Profanity
streaming
transcription timestamps filtering
transcription

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Demo: speech timestamps

1 2 3
Extract audio from Send audio to Cloud Visualize & search
a video Speech for transcription videos in a UI
& timestamps
Cut Video

Translation + NL

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cloud Translation
Translate text into 100+ languages

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Translate Detect
text language

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cloud Natural
Language
Understand text with a simple
REST API request

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Extract Detect Analyze Classify
entities sentiment syntax content

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Analyze syntax

det nn nn nsubj root nsubj ccomp dobj p

The natural language API helps us understand text .


DET NOUN NOUN NOUN VERB PRON VERB NOUN PUNCT

help

Number = SINGULAR Number = SINGULAR Number = SINGULAR Mood = INDICATIVE Case = ACCUSATIVE Number = SINGULAR
Proper = PROPER Proper = PROPER Proper = PROPER Number = SINGULAR Number = PLURAL
Person = THIRD Person = FIRST
Tense = Present

Dependency Parse label Part of speech Lemma Morphology

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Classify content using Cloud Natural Language

{ categories:
[
{
name: '/Sports/Team
Sports/Baseball',
confidence: 0.99
Rafael Montero Shines in Mets’ Victory Over the Reds. Montero, who }
was demoted at midseason, took a one-hitter into the ninth inning as ]
the Mets continued to dominate Cincinnati with a win at Great }

American Ball Park.

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Wootric: Cloud Natural Language in production

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Wootric: analyzing and routing feedback

● Make sense of millions of


qualitative customer feedback
each week using entity and
sentiment analysis

● Route and respond to feedback


in near realtime, compared to
manually classifying each
response

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Try Cloud NL in the browser

cloud.google.com/natural-language
© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Cut Video

Lab on ML APIs

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
88

Lab: Invoking Machine Learning APIs

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
Lab: Invoke Machine Learning APIs

In this lab, you invoke 1. Clone the code repository within


ready-to-use Machine your Datalab
Learning APIs in your Datalab
environment 2. Save the code repo in your Cloud
project’s source repositories

3. Enable ML APIs in your Cloud


project

4. Invoke ML APIs from Datalab

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
The ML APIs are microservices that provide a high level of
abstraction

When we build ML models


ourselves, it should be our goal
to make them:

- easy to use and


- stand-alone.

© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.
cloud.google.com
Images by Connie Zhou
© 2017 Google Inc. All rights reserved. Google and the Google logo are trademarks of Google Inc. All other
company and product names may be trademarks of the respective companies with which they are associated.

You might also like