Slide 1

Slide 1 text

& APACHE SPARK MLlib APACHE SPARK MLlib

Slide 2

Slide 2 text

2 PARTS: APACHE SPARK MLlib

Slide 3

Slide 3 text

2 PARTS: APACHE SPARK what is

Slide 4

Slide 4 text

2 PARTS: MLlib how do I use on spark?

Slide 5

Slide 5 text

PART I APACHE SPARK what is

Slide 6

Slide 6 text

DATA

Slide 7

Slide 7 text

DATA IS EVERYWHERE

Slide 8

Slide 8 text

DATA IS UNLIMITED

Slide 9

Slide 9 text

DATA IS BIG

Slide 10

Slide 10 text

BIG DATA IS HARD and

Slide 11

Slide 11 text

CHALLENGES WITH BIG DATA 1. Capturing

Slide 12

Slide 12 text

CHALLENGES WITH BIG DATA 1. Capturing 2. Storing

Slide 13

Slide 13 text

CHALLENGES WITH BIG DATA 1. Capturing 2. Storing 3. Analyzing

Slide 14

Slide 14 text

REAL WORLD EXAMPLE

Slide 15

Slide 15 text

1 TWEET @addamh: Tacos are the best . Tom Brady is the best. So, Tom Brady is . @addamh: Tacos are the best . Tom Brady is the best. So, Tom Brady is .

Slide 16

Slide 16 text

6000 TWEETS / SECOND X 12 MB / SECOND = ~ 200 BYTES / TWEET X 1 TWEET @addamh: Tacos are the best . Tom Brady is the best. So, Tom Brady is .

Slide 17

Slide 17 text

6000 TWEETS / SECOND X 12 MB / SECOND = ~ 200 BYTES / TWEET X 24 HOURS X 1TB / DAY = 1 TWEET @addamh: Tacos are the best . Tom Brady is the best. So, Tom Brady is . @addamh: Tacos are the best . Tom Brady is the best. So, Tom Brady is .

Slide 18

Slide 18 text

6000 TWEETS / SECOND X 12 MB / SECOND = ~ 200 BYTES / TWEET X 24 HOURS X 1TB / DAY = 30 DAYS / MONTH X 30TB / MONTH = 1 TWEET @addamh: Tacos are the best . Tom Brady is the best. So, Tom Brady is . @addamh: Tacos are the best . Tom Brady is the best. So, Tom Brady is .

Slide 19

Slide 19 text

…and that’s just Twitter…on an average day.

Slide 20

Slide 20 text

BIG DATA IS NOT BULLSHIT

Slide 21

Slide 21 text

CHALLENGES WITH BIG DATA 1. Capturing 2. Storing 3. Analyzing

Slide 22

Slide 22 text

CHALLENGES WITH BIG DATA 1. Capturing 2. Storing 3. Analyzing

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

DISTRIBUTED COMPUTING PLATFORM

Slide 25

Slide 25 text

IS NOT A BETTER HADOOP.

Slide 26

Slide 26 text

WORKS IN MEMORY. NOT ON DISK.

Slide 27

Slide 27 text

USES RESILIENT DISTRIBUTED DATASETS.

Slide 28

Slide 28 text

WHAT IS AN RDD?

Slide 29

Slide 29 text

DATA ARRAY RDD RDD Partition Host 02 RAM partition RAM partition RAM partition RAM partition Host 01 RAM partition RAM partition RAM partition RAM partition Host n RAM partition RAM partition RAM partition RAM partition RDD Partition RDD Partition RDD Partition RDD Partition

Slide 30

Slide 30 text

MACHINE LEARNING ON SPARK?

Slide 31

Slide 31 text

MACHINE LEARNING ON SPARK? MLlib

Slide 32

Slide 32 text

WHY MLlib?

Slide 33

Slide 33 text

BUILT ON SPARK. FOR SPARK.

Slide 34

Slide 34 text

BUILT ON SPARK. FOR SPARK. ML ALGORITHMS WITH 100X SPEED INCREASES OVER MAP REDUCE

Slide 35

Slide 35 text

PART II MLlib how do I use on spark?

Slide 36

Slide 36 text

MLlib is a machine learning toolbox that is tightly integrated into Spark and has an RDD API. This allows MLlib’s algorithms to run on a distributed Spark cluster.

Slide 37

Slide 37 text

MLlib Classification: Logistic Regression Naive Bayes Decision Trees: Random Forests Gradient-Boost Trees Clustering: K-means Topic Modeling: latent Dirichlet allocation Recommendation: Alternating Least Squares Regression: Linear Regression Isotonic Regression is a machine learning toolbox that is tightly integrated into Spark and has an RDD API. This allows MLlib’s algorithms to run on a distributed Spark cluster.

Slide 38

Slide 38 text

MLlib Classification: Logistic Regression Naive Bayes Decision Trees: Random Forests Gradient-Boost Trees Clustering: K-means Topic Modeling: latent Dirichlet allocation Recommendation: Alternating Least Squares Regression: Linear Regression Isotonic Regression is a machine learning toolbox that is tightly integrated into Spark and has an RDD API. This allows MLlib’s algorithms to run on a distributed Spark cluster.

Slide 39

Slide 39 text

COLLABORATIVE FILTERING

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

?

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

? ? ?

Slide 47

Slide 47 text

? ? ? 2 3 5 2 4 3 2 4 5 5 1 4 5

Slide 48

Slide 48 text

3 5 ? 5 2 5 1 4 ? 4 2 3 5 2 ? 4 ω = Our data as a dense matrix:

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

Minimization Problem Non-Convex Problem

Slide 51

Slide 51 text

WHERE IS THE GLOBAL MINIMA? Non-Convex

Slide 52

Slide 52 text

WHERE IS THE GLOBAL MINIMA? Not easy to find Non-Convex

Slide 53

Slide 53 text

LOW-RANK MATRIX FACTORIZATION IS A NON-CONVEX PROBLEM. THIS MAKES FINDING THE GLOBAL MINIMA VERY COSTLY. THE ALTERNATING LEAST SQUARES ALGORITHM ALLOWS US CONVERT TO A CONVEX PROBLEM.

Slide 54

Slide 54 text

WHERE IS THE GLOBAL MINIMA? Much Easier Convex

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

IT’S NOT THIS HARD I PROMISE

Slide 57

Slide 57 text

MLlib HAS ALREADY DONE THE HARD WORK.

Slide 58

Slide 58 text

LET’S LOOK AT SOME CODE

Slide 59

Slide 59 text

COLLECT YOUR DATA

Slide 60

Slide 60 text

Movielens Data movieId,title,genres 1,Toy Story (1995),Adventure|Animation|Children|Comedy|Fantasy 2,Jumanji (1995),Adventure|Children|Fantasy 3,Grumpier Old Men (1995),Comedy|Romance 4,Waiting to Exhale (1995),Comedy|Drama|Romance 5,Father of the Bride Part II (1995),Comedy 6,Heat (1995),Action|Crime|Thriller 7,Sabrina (1995),Comedy|Romance 8,Tom and Huck (1995),Adventure|Children 9,Sudden Death (1995),Action 10,GoldenEye (1995),Action|Adventure|Thriller 11,"American President, The (1995)",Comedy|Drama|Romance 12,Dracula: Dead and Loving It (1995),Comedy|Horror 13,Balto (1995),Adventure|Animation|Children

Slide 61

Slide 61 text

Ratings userId,movieId,rating,timestamp 1,31,2.5,1260759144 1,1029,3.0,1260759179 1,1061,3.0,1260759182 1,1129,2.0,1260759185 1,1172,4.0,1260759205 1,1263,2.0,1260759151 1,1287,2.0,1260759187 1,1293,2.0,1260759148 1,1339,3.5,1260759125

Slide 62

Slide 62 text

PULL IN MLlib

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

SPLIT OUR DATA

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

TRAIN THE MODEL AND TUNE THE PARAMETERS

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

Train multiple models to find best rank parameter

Slide 69

Slide 69 text

Train multiple models to find best rank parameter Compute Root-Mean-Square Error

Slide 70

Slide 70 text

Train multiple models to find best rank parameter Compute Root-Mean-Square Error Lowest wins

Slide 71

Slide 71 text

INPUT YOUR NEW RATINGS

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

(userId, movieId, rating)

Slide 74

Slide 74 text

(userId, movieId, rating) Distribute RDD to the Spark cluster

Slide 75

Slide 75 text

TRAIN A NEW MODEL BASED ON YOUR RATINGS

Slide 76

Slide 76 text

Merge new ratings with full rating set

Slide 77

Slide 77 text

Merge new ratings with full rating set Train an updated model with the new ratings

Slide 78

Slide 78 text

GET PREDICTIONS WITH THE UPDATED MODEL

Slide 79

Slide 79 text

Get IDs of movies just rated

Slide 80

Slide 80 text

Remove just rated movies from ratings RDD Get IDs of movies just rated

Slide 81

Slide 81 text

Remove just rated movies from ratings RDD Make predictions for unrated movies from full dataset Get IDs of movies just rated

Slide 82

Slide 82 text

FIND THE MOVIES YOU DIDN’T KNOW YOU ❤

Slide 83

Slide 83 text

Get top 10 recommendations

Slide 84

Slide 84 text

Get top 10 recommendations Print them out

Slide 85

Slide 85 text

No content

Slide 86

Slide 86 text

YOU DON’T HAVE TO BE A DATA SCIENTIST TO START GETTING VALUE FROM THE TOOLS.

Slide 87

Slide 87 text

ADDAM HARDY @addamh Come talk to us about your data