build your own recommendation engine

14
Build Your Own Recommendation Engine (during Weekend) Michal Malohlava @mmalohlava && @h2oai presents

Upload: jo-fai-chow

Post on 16-Apr-2017

1.314 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Build Your Own Recommendation Engine

Build Your Own Recommendation Engine

(during Weekend)

Michal Malohlava @mmalohlava && @h2oai

presents

Page 2: Build Your Own Recommendation Engine

Mus

ic S

ervi

ce

Activities clicks/swipes/likes

Clients iOS/Android/…

Next N-recommendations

? REBB*?

*REBB = Recommendation Engine Black Box

Page 3: Build Your Own Recommendation Engine

Requ

irem

ents

Activities can be >100/s

REBB should be accessible via REST API

Recommendations need to be served <500ms, should keep users exploring

AWS infrastructure

Need to be ready in 2 days!

Page 4: Build Your Own Recommendation Engine

Requirements• Recommendations should be served <500ms

• ML part should allow quick prototyping & experimentation

• Storage (online/offline) - user stats, histories, recommendations

• Scalable

• frontend receiving requests

• backend solving ML

• storage Need to be ready in 2 days!

Page 5: Build Your Own Recommendation Engine

Engine Architecture

Variation of λ-architecture…

… with pluggable ML backend

Page 6: Build Your Own Recommendation Engine

Engine Architecture

Regular EC2 nodes

Page 7: Build Your Own Recommendation Engine

API Router

REST API via Spray

Akka Actor accepting and filtering: • user activities • recommendation requests

Scalable via HAProxy

Page 8: Build Your Own Recommendation Engine

API Router

Akka Actor handles

• POST of user activity

• publish activity to Redis

• update stats in Redis (quick updates)

• trigger recommendation computation

Page 9: Build Your Own Recommendation Engine

API Router

Akka Actor handles

• GET recommendation request

• fetch pre-computed recommendation from Redis if exists

• OR try to do best-effort to provide “coldstart" recommendation based on history of user activities

Page 10: Build Your Own Recommendation Engine

Redis StoreRedis is used as

• events bus: • inform subscribers about user

activities • requests to provide new

recommendation for user

• data storage • old/new recommendations • statistics (likes/swipe per user) • simple persistence model

• computation engine • keep top-N artists, top-N songs per user

Page 11: Build Your Own Recommendation Engine

ML BackendLanguage/technology agnostic

• Needs to be flexible enough to prototype different strategies

“Runners” for

• generating recommendationswith H2O and Python

• collecting/generating statistics

• clustering users with H2O JVM

“Runners” are subscribed to Redis/processing Redis data

Page 12: Build Your Own Recommendation Engine

ML BackendFinal strategy

• identify user cluster based on users activities (aka music styles)

• apply different recommendationstrategies inside each cluster

• identify “weird” users (~outliers)

• adapt recommendation for them

• needs manual intervention/algorithm tuning

Page 13: Build Your Own Recommendation Engine

Results

• Single machine for API Router and Redis

• peeks 50 activities/sec, avg 10 activities/sec

• small memory footprint

• ML Runners spread over EC2 machines

• even simple but different strategies for each user sectors and selected individual users provides surprisingly good results

Page 14: Build Your Own Recommendation Engine

Learn more at h2o.ai Follow us at @h2oai

Thank you!