data day seattle 2015: sarah guido

33
Data Science at Scale: Using Apache Spark for Data Science at Bitly Sarah Guido Data Day Seattle 2015

Upload: bitly

Post on 22-Mar-2017

521 views

Category:

Data & Analytics


2 download

TRANSCRIPT

Page 1: Data Day Seattle 2015: Sarah Guido

Data Science at Scale:Using Apache Spark for Data Science at Bitly

Sarah GuidoData Day Seattle 2015

Page 2: Data Day Seattle 2015: Sarah Guido

Overview

• About me/Bitly• Spark overview• Using Spark for data science• When it works, it’s great! When it works…

Page 3: Data Day Seattle 2015: Sarah Guido

About me

• Data scientist at Bitly• NYC Python/PyGotham co-organizer• O’Reilly Media author• @sarah_guido

Page 4: Data Day Seattle 2015: Sarah Guido

About this talk

• This talk is:– Description of my workflow– Exploration of within-Spark tools

• This talk is not:– In-depth exploration of algorithms– Building new tools on top of Spark– Any sort of ground truth for how you should be

using Spark

Page 5: Data Day Seattle 2015: Sarah Guido

A bit of background

• Need for big data analysis tools• MapReduce for exploratory data analysis == • Iterate/prototype quickly• Overall goal: understand how people use not

only our app, but the Internet!

Page 6: Data Day Seattle 2015: Sarah Guido

Bitly data!

• Legit big data• 1 hour of decodes is 10 GB• 1 day is 240 GB• 1 month is ~7 TB

Page 7: Data Day Seattle 2015: Sarah Guido

Why Spark?

• Fast. Really fast.• Distributed scientific tools• Python! Sometimes.• Cutting edge technology

Page 8: Data Day Seattle 2015: Sarah Guido

Setting up the workflow

• Spark journey– Hadoop server: 1.2– EMR: 1.3– EMR: 1.4– EMR: 1.5! Jupyter Notebook running Scala!

Page 9: Data Day Seattle 2015: Sarah Guido

How do I use it?

• EMR!• spark-submit on the cluster• Can add script as a step to cluster launch

Page 10: Data Day Seattle 2015: Sarah Guido

Let’s set the stage…

• Understanding user behavior• How do I extract, explore, and model a subset

of our data using Spark?

Page 11: Data Day Seattle 2015: Sarah Guido

Data{"a": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.4.10 (KHTML, like Gecko) Version/8.0.4 Safari/600.4.10", "c": "US", "nk": 0, "tz": "America/Los_Angeles", "g": "1HfTjh8", "h": "1HfTjh7", "u": "http://www.nytimes.com/2015/03/22/opinion/sunday/why-health-care-tech-is-still-so-bad.html?smid=tw-share", "t": 1427288425, "cy": "Seattle"}

Page 12: Data Day Seattle 2015: Sarah Guido

Data processing

• Problem: I want to retrieve NYT decodes• Solution: well, there are two…

Page 13: Data Day Seattle 2015: Sarah Guido

Data processing

Page 14: Data Day Seattle 2015: Sarah Guido

Data processing

Page 15: Data Day Seattle 2015: Sarah Guido

Data processing

• SparkSQL: 8 minutes• Pure Spark: 4 minutes!!!

Page 16: Data Day Seattle 2015: Sarah Guido

Data processing

Page 17: Data Day Seattle 2015: Sarah Guido

Exploratory data analysis

• Problem: what’s going on with my decodes?• Solution: DataFrames!– Similar to Pandas: describe, drop, fill, aggregate

functions– You can actually convert to a Pandas DataFrame!

Page 18: Data Day Seattle 2015: Sarah Guido

Exploratory data analysis

• Get a sense of what’s going on in the data• Look at distributions, frequencies• Mostly categorical data here

Page 19: Data Day Seattle 2015: Sarah Guido

Topic modeling

• Problem: we have so many links but no way to classify them into certain kinds of content

• Solution: LDA (latent Dirichlet allocation)– Sort of – compare to other solutions

Page 20: Data Day Seattle 2015: Sarah Guido

Topic modeling

• Oh, the JVM…– LDA only in Scala

• Scala jar file• Store script in S3

Page 21: Data Day Seattle 2015: Sarah Guido

Topic modeling

• LDA in Spark– Generative model– Several different methods– Term frequency vector as input

• “Note: LDA is a new feature with some missing functionality...”

Page 22: Data Day Seattle 2015: Sarah Guido

Topic modeling

Page 23: Data Day Seattle 2015: Sarah Guido

Topic modeling

• Term frequency vector

TERMDOCUMENT

python data hot dogs baseball zoo

doc_1 1 3 0 0 0

doc_2 0 0 4 1 0

doc_3 4 0 0 0 5

Page 24: Data Day Seattle 2015: Sarah Guido

Topic modeling

Page 25: Data Day Seattle 2015: Sarah Guido

Topic modeling

Page 26: Data Day Seattle 2015: Sarah Guido

Topic modeling

• Why not??– Means to an end– Current large scale scraping inability

Page 27: Data Day Seattle 2015: Sarah Guido

Trend Detection

• Eventually realtime with Spark Streaming

Page 28: Data Day Seattle 2015: Sarah Guido

Architecture

• Right now: not in production– Buy-in

• Streaming applications for parts of the app• Python or Scala?– Scala by force (LDA, GraphX)

Page 29: Data Day Seattle 2015: Sarah Guido

Some issues

• Hadoop servers• JVM• gzip• 1.4• Resource allocation• Really only got it to this stage very recently

Page 30: Data Day Seattle 2015: Sarah Guido

Where to go next?

• Spark in production!• Use for various parts of our app• Use for R&D and prototyping purposes, with

the potential to expand into the product

Page 31: Data Day Seattle 2015: Sarah Guido

Current/future projects

• Trend detection• Device prediction• User affinities– GraphX!

• A/B testing

Page 32: Data Day Seattle 2015: Sarah Guido

Resources

• spark.apache.org - documentation• Databricks blog• Cloudera blog

Page 33: Data Day Seattle 2015: Sarah Guido

Thanks!!

@sarah_guido