your own recommendation engine with neo4j and reco4php - dpc16
Post on 13-Apr-2017
321 Views
Preview:
TRANSCRIPT
YourownRecommendation
EnginewithNeo4j andReco4PHP
Aboutme
• ChristopheWillemsen
• Neo4j&Elasticsearch Consultant@GraphAware
• Belgium
@ikwattro
Whatwe’lltalkabout
• Challengesofarecommendationengine
• Quickintrotographdatabases(Neo4j)
• Reco4PHP
• Buildyourown(demo)
Challengesofa
RecommendationEngine
Recommendations:Overview
• Newsyoushouldread(blogs)• Booksyoushouldbuy(e-commerce)• Personsyoumayknow(social)• Whichtalktoattend(knowledge)• Whichserviceisbestsuitedtohandleagivenfailure(impactanalysis)• Findingtherightcandidatesformedicalproofs(healthcare)• …
Maintypesofrecommendations
• Contentbased(features)• Collaborativefiltering(relationsuser<->item,knn,matrixfactorization)• Knowledgebased
Combinationofthosebycompletelycrazyscientists+secretsauce
BusinessChallenges
• Findingthingstorecommend
• Servethemostrelevantrecommendations
•Measuringthequalityofrecommendations
• Timetomarket/costofdevelopment
Businesschallenges
Imaginethatyoushouldimplementthefeature
“Peopleyoumayknow”onLinkedIn
Businesschallenges:Findingcandidates• Commoncontacts• Facebookfriendsincommon•Mobile/emailcontactsincommon• Allcontactsofyourcontacts•Workedforsamecompany• Studiedatsameschool• Sharesameinterests• Livesinsamecity
Businesschallenges
It’sjustthebeginning!
Let’srevisit…
Businesschallenges:mostrelevant
Morecontactsincommon:
Morerelevant?
Businesschallenges:mostrelevant
Samecity,workedforsamecompany,studiedatsameschool
Businesschallenges:mostrelevant
Whattodowithemailsthatactuallydon’trepresentaperson?
Shouldwerecommend info@coolblue.nl?
Businesschallenges:mostrelevant
Whatshouldwedowithcontacts
pending?rejected?
alwaysignored?
TechnicalChallenges
• Simplicity
• Performance(Real-timeornearreal-time)
• Flexibility
IntrotoGraphDatabases
(Neo4j)
isagraphdatabase.
Nodes
Anodecanhaveoneormultiplelabels
Person, Male
Anodecanoneormoreproperties
Person, Male
name : Mark
Nodesareconnectedbyrelationships
Relationshipshaveatype
Relationshipshaveadirection
Relationshipscanhaveproperties
Cypher:thequerylanguageforgraphs
Declarativepatternmatchinglanguage
Describewhatyouwant
toretrievefromthedatabase,not
howtogetit.
Declarativepatternmatchinglanguage
MATCH(you:Person {name:”You”})-[:ATTENDED]->(talk),
(talk)<-[:ATTENDED]-(other)
WHERE(you)-[:LIVES_IN]->(city)<-[:LIVES_IN]-(other)
ANDyou <>other
RETURNother ASmaybeFriend
Whygraphs?
TechnicalChallenges
• Simplicity
• Performance(Real-timeornearreal-time)
• Flexibility
Simplicity
Features aswellasrelationships arenaturallyrepresentedin
agraph database.
Simplicity
Therecommendation logiccanberepresentedinagraphtraversal.
TechnicalChallenges
• Simplicity
• Performance(Real-time)
• Flexibility
Performance
• Relationshipsarefirstclasscitizens(nojoins!)• TraversingrelationshipsinNeo4jischeap(4millionstraversalspersecondpercore)
Reco4PHP
OpenSourceRecommendationEngine
SkeletonatopNeo4j
Reco4PHP
• StandalonePHPlibrary• Opinionatedarchitecture• Flexible• Handlealltheglue
Architecture
• Input->DiscoveryEngines->Recommendations• ScoresandScorebuilders• BlacklistsandFilters• PostProcessors• Context(howmany,meteo,allk/vexternalfactors..)
Designdecisions
• DiscoveryEngine perrecommendation“reason”(corelogic)• DiscoveryEngine executesagraphtraversal(Cypherquery)• Itemsdiscoveredmultipletimesaremorerelevant
TechnicalChallenges
• Simplicity
• Performance(Real-timeornearreal-time)
• Flexibility
Let’sbuildone
In5minutes,we’llbuildasimpleenginethatrecommendsrepositoriesyoumightbeinterestedinonGithub.
composerrequiregraphaware/reco4php
0.TheModel
:STARS
:CONTRIBUTED_TO:OWNS
:FOLLO
WS:FOLLOWS
:WRITTEN_IN
1.Discover
Findrepositoriesstarredbythepeopleyoufolloworfollowingyou.
2.Serveonlyrelevantrecommendations
We’llcreateablacklistthatwillexcludetherepositoriesIamtheownerof.
3.Postprocess
We’llrewardtherecommendedrepositoriesbylet’ssay5pointsiftheyarewritteninPHP.
4.Assemble
5.Tadaaaaaam
Thankyou!
Questions?
graphaware.comgithub.com/graphaware
@ikwattro
top related