your own recommendation engine with neo4j and reco4php - dpc16

59
Your own Recommendation Engine with Neo4j and Reco4PHP

Upload: christophe-willemsen

Post on 13-Apr-2017

320 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Your own recommendation engine with neo4j and reco4php - DPC16

YourownRecommendation

EnginewithNeo4j andReco4PHP

Page 2: Your own recommendation engine with neo4j and reco4php - DPC16

Aboutme

• ChristopheWillemsen

• Neo4j&Elasticsearch Consultant@GraphAware

• Belgium

@ikwattro

Page 3: Your own recommendation engine with neo4j and reco4php - DPC16

Whatwe’lltalkabout

• Challengesofarecommendationengine

• Quickintrotographdatabases(Neo4j)

• Reco4PHP

• Buildyourown(demo)

Page 4: Your own recommendation engine with neo4j and reco4php - DPC16

Challengesofa

RecommendationEngine

Page 5: Your own recommendation engine with neo4j and reco4php - DPC16

Recommendations:Overview

• Newsyoushouldread(blogs)• Booksyoushouldbuy(e-commerce)• Personsyoumayknow(social)• Whichtalktoattend(knowledge)• Whichserviceisbestsuitedtohandleagivenfailure(impactanalysis)• Findingtherightcandidatesformedicalproofs(healthcare)• …

Page 6: Your own recommendation engine with neo4j and reco4php - DPC16

Maintypesofrecommendations

• Contentbased(features)• Collaborativefiltering(relationsuser<->item,knn,matrixfactorization)• Knowledgebased

Page 7: Your own recommendation engine with neo4j and reco4php - DPC16

Combinationofthosebycompletelycrazyscientists+secretsauce

Page 8: Your own recommendation engine with neo4j and reco4php - DPC16

BusinessChallenges

• Findingthingstorecommend

• Servethemostrelevantrecommendations

•Measuringthequalityofrecommendations

• Timetomarket/costofdevelopment

Page 9: Your own recommendation engine with neo4j and reco4php - DPC16

Businesschallenges

Imaginethatyoushouldimplementthefeature

“Peopleyoumayknow”onLinkedIn

Page 10: Your own recommendation engine with neo4j and reco4php - DPC16

Businesschallenges:Findingcandidates• Commoncontacts• Facebookfriendsincommon•Mobile/emailcontactsincommon• Allcontactsofyourcontacts•Workedforsamecompany• Studiedatsameschool• Sharesameinterests• Livesinsamecity

Page 11: Your own recommendation engine with neo4j and reco4php - DPC16

Businesschallenges

It’sjustthebeginning!

Let’srevisit…

Page 12: Your own recommendation engine with neo4j and reco4php - DPC16

Businesschallenges:mostrelevant

Morecontactsincommon:

Morerelevant?

Page 13: Your own recommendation engine with neo4j and reco4php - DPC16

Businesschallenges:mostrelevant

Samecity,workedforsamecompany,studiedatsameschool

Page 14: Your own recommendation engine with neo4j and reco4php - DPC16
Page 15: Your own recommendation engine with neo4j and reco4php - DPC16

Businesschallenges:mostrelevant

Whattodowithemailsthatactuallydon’trepresentaperson?

Shouldwerecommend [email protected]?

Page 16: Your own recommendation engine with neo4j and reco4php - DPC16

Businesschallenges:mostrelevant

Whatshouldwedowithcontacts

pending?rejected?

alwaysignored?

Page 17: Your own recommendation engine with neo4j and reco4php - DPC16

TechnicalChallenges

• Simplicity

• Performance(Real-timeornearreal-time)

• Flexibility

Page 18: Your own recommendation engine with neo4j and reco4php - DPC16

IntrotoGraphDatabases

(Neo4j)

Page 19: Your own recommendation engine with neo4j and reco4php - DPC16
Page 20: Your own recommendation engine with neo4j and reco4php - DPC16

isagraphdatabase.

Page 21: Your own recommendation engine with neo4j and reco4php - DPC16

Nodes

Page 22: Your own recommendation engine with neo4j and reco4php - DPC16

Anodecanhaveoneormultiplelabels

Person, Male

Page 23: Your own recommendation engine with neo4j and reco4php - DPC16

Anodecanoneormoreproperties

Person, Male

name : Mark

Page 24: Your own recommendation engine with neo4j and reco4php - DPC16

Nodesareconnectedbyrelationships

Page 25: Your own recommendation engine with neo4j and reco4php - DPC16

Relationshipshaveatype

Page 26: Your own recommendation engine with neo4j and reco4php - DPC16

Relationshipshaveadirection

Page 27: Your own recommendation engine with neo4j and reco4php - DPC16

Relationshipscanhaveproperties

Page 28: Your own recommendation engine with neo4j and reco4php - DPC16
Page 29: Your own recommendation engine with neo4j and reco4php - DPC16

Cypher:thequerylanguageforgraphs

Page 30: Your own recommendation engine with neo4j and reco4php - DPC16

Declarativepatternmatchinglanguage

Describewhatyouwant

toretrievefromthedatabase,not

howtogetit.

Page 31: Your own recommendation engine with neo4j and reco4php - DPC16

Declarativepatternmatchinglanguage

MATCH(you:Person {name:”You”})-[:ATTENDED]->(talk),

(talk)<-[:ATTENDED]-(other)

WHERE(you)-[:LIVES_IN]->(city)<-[:LIVES_IN]-(other)

ANDyou <>other

RETURNother ASmaybeFriend

Page 32: Your own recommendation engine with neo4j and reco4php - DPC16

Whygraphs?

Page 33: Your own recommendation engine with neo4j and reco4php - DPC16

TechnicalChallenges

• Simplicity

• Performance(Real-timeornearreal-time)

• Flexibility

Page 34: Your own recommendation engine with neo4j and reco4php - DPC16
Page 35: Your own recommendation engine with neo4j and reco4php - DPC16

Simplicity

Features aswellasrelationships arenaturallyrepresentedin

agraph database.

Page 36: Your own recommendation engine with neo4j and reco4php - DPC16

Simplicity

Therecommendation logiccanberepresentedinagraphtraversal.

Page 37: Your own recommendation engine with neo4j and reco4php - DPC16
Page 38: Your own recommendation engine with neo4j and reco4php - DPC16
Page 39: Your own recommendation engine with neo4j and reco4php - DPC16

TechnicalChallenges

• Simplicity

• Performance(Real-time)

• Flexibility

Page 40: Your own recommendation engine with neo4j and reco4php - DPC16

Performance

• Relationshipsarefirstclasscitizens(nojoins!)• TraversingrelationshipsinNeo4jischeap(4millionstraversalspersecondpercore)

Page 41: Your own recommendation engine with neo4j and reco4php - DPC16

Reco4PHP

OpenSourceRecommendationEngine

SkeletonatopNeo4j

Page 42: Your own recommendation engine with neo4j and reco4php - DPC16

Reco4PHP

• StandalonePHPlibrary• Opinionatedarchitecture• Flexible• Handlealltheglue

Page 43: Your own recommendation engine with neo4j and reco4php - DPC16

Architecture

• Input->DiscoveryEngines->Recommendations• ScoresandScorebuilders• BlacklistsandFilters• PostProcessors• Context(howmany,meteo,allk/vexternalfactors..)

Page 44: Your own recommendation engine with neo4j and reco4php - DPC16

Designdecisions

• DiscoveryEngine perrecommendation“reason”(corelogic)• DiscoveryEngine executesagraphtraversal(Cypherquery)• Itemsdiscoveredmultipletimesaremorerelevant

Page 45: Your own recommendation engine with neo4j and reco4php - DPC16

TechnicalChallenges

• Simplicity

• Performance(Real-timeornearreal-time)

• Flexibility

Page 46: Your own recommendation engine with neo4j and reco4php - DPC16

Let’sbuildone

In5minutes,we’llbuildasimpleenginethatrecommendsrepositoriesyoumightbeinterestedinonGithub.

Page 47: Your own recommendation engine with neo4j and reco4php - DPC16

composerrequiregraphaware/reco4php

Page 48: Your own recommendation engine with neo4j and reco4php - DPC16

0.TheModel

:STARS

:CONTRIBUTED_TO:OWNS

:FOLLO

WS:FOLLOWS

:WRITTEN_IN

Page 49: Your own recommendation engine with neo4j and reco4php - DPC16

1.Discover

Findrepositoriesstarredbythepeopleyoufolloworfollowingyou.

Page 50: Your own recommendation engine with neo4j and reco4php - DPC16
Page 51: Your own recommendation engine with neo4j and reco4php - DPC16

2.Serveonlyrelevantrecommendations

We’llcreateablacklistthatwillexcludetherepositoriesIamtheownerof.

Page 52: Your own recommendation engine with neo4j and reco4php - DPC16
Page 53: Your own recommendation engine with neo4j and reco4php - DPC16

3.Postprocess

We’llrewardtherecommendedrepositoriesbylet’ssay5pointsiftheyarewritteninPHP.

Page 54: Your own recommendation engine with neo4j and reco4php - DPC16
Page 55: Your own recommendation engine with neo4j and reco4php - DPC16

4.Assemble

Page 56: Your own recommendation engine with neo4j and reco4php - DPC16
Page 57: Your own recommendation engine with neo4j and reco4php - DPC16

5.Tadaaaaaam

Page 58: Your own recommendation engine with neo4j and reco4php - DPC16
Page 59: Your own recommendation engine with neo4j and reco4php - DPC16

Thankyou!

Questions?

graphaware.comgithub.com/graphaware

@ikwattro