SlideShare a Scribd company logo
Adding a
Recommendation
     Engine
    WindyCityDB
    Max De Marzi
About Me
    Built the Neography Gem (Ruby
    Wrapper to the Neo4j REST API)
    Playing with Neo4j since 10/2009


•   My Blog: http://maxdemarzi.com
•   Find me on Twitter: @maxdemarzi
•   Email me: maxdemarzi@gmail.com
•   GitHub: http://github.com/maxdemarzi
Agenda
•   What is Neo4j?
•   What is Neography?
•   Approaches
•   Gremlin
•   Gremlin Recommends
•   Cypher
•   Cypher Recommends
What is Neo4j?
• A Graph Database + Lucene Index
• Property Graph
• Full ACID (atomicity, consistency, isolation,
  durability)
• High Availability (with Enterprise Edition)
• 32 Billion Nodes, 32 Billion Relationships,
  64 Billion Properties
• Embedded Server (Java or JVM languages)
• REST API (for everyone else)
Obligatory CAP theorem Slide
              • Neo4j is at the section
                joining Consistency
                with Availability just
                like your RDBMS
Good For
• Highly connected data (social networks)
• Recommendations (e-commerce)
• Path Finding (how do I know you?)

• A* (Least Cost path)
• Data First Schema (bottom-up, but you still
  need to design)
Property Graph
If you’ve ever
•   Joined more than 7 tables together
•   Modeled a graph in a table
•   Written a recursive CTE
•   Tried to write some crazy stored procedure
    with multiple recursive self and inner joins

    You should use Neo4j
What is Neography?
A very thin wrapper to
          the Neo4j REST API
• Two layers:
  Following the REST API
  Ruby Sugar
• Made for graph database programmer happiness
  >8-]
• Read the github Readme and Specs
• Can I haz pull requests?
• Want Active Record?
  Use the activerecord-neo4j-adapter gem which
  sits on top of neography
How do I install Neo4j?




Create a project directory and
do this now if you haven’t yet.

Make sure wget is installed.
Approaches
Collaborative Filtering
• Step 1: Collect User
  Behavior
• Step 2: Find similar
  Users
• Step 3: Recommend
  Behavior taken by
  similar users
Content Based Filtering
• Step 1: Collect Item
  Characteristics
• Step 2: Find similar
  Items
• Step 3: Recommend
  Similar Items


Marko likes Romantic Zombie Comedies,
what other romantic zombie comedies are there?

Tweet him @twarko
Hybrid
• Combine the two for
  better results.

• Example: Netflix
What is Gremlin?
Gremlin is
• A Graph Traversal Language
• A domain specific language for traversing
  property graphs
• Implemented by most Graph Database
  Vendors
• Primarily seen with the Groovy Language
• With JVM connectivity in Java, Scala, and
  other languages
Created by:
Marko Rodriguez
http://markorodriguez.com
A Graph DSL




A Dynamic Language for the JVM




A Data Flow Framework




“JDBC” for Graph DBs
Gremlin Recommends
Hybrid movie recommendations
Our Graph (from MovieLens)
Recommendation Algorithm
m = [:];
x = [] as Set;           (continued)
v = g.v(node_id);        outV.
                         outE('rated').
v.                       filter{it.stars > 3}.
out('hasGenre').         inV.
aggregate(x).            filter{it != v}.
back(2).                 filter{it.out('hasGenre').toSet().equals(x)}.
inE('rated').            groupCount(m){"${it.id}:${it.title}"}.iterate();
filter{it. stars > 3}.   m.sort{a,b -> b.value <=> a.value}[0..24]
Explanation
m = [:];
x = [] as Set;
v = g.v(node_id);




In Groovy [:] is a map, we will return this
The set “x” will hold the collection of genres we want our recommended
movies to have.

v is our starting point.
Explanation
v.
out('hasGenre').       (we are now at a genre node)
aggregate(x).




We fill the empty set “x” with the genres of our movie.
These are the properties we want to make sure our recommendations have.
Explanation
back(2).                 (we are back to our starting point)
inE('rated').
filter{it. stars > 3}.   (we are now at the link between our movie and users)




We go back two steps to our starting movie, go to the relationship ‘rated’
and filter it so we only keep those with more than 3 stars.
Explanation
outV.                   (we are now at a user node)
outE('rated').
filter{it.stars > 3}.   (we are now at the link between user and movie)




We follow our relationships to the users who made them, and then
go to the “rated” relationships of movies which also received more
than 3 stars.
Explanation
inV.                 (we are now at a movie node)
filter{it != v}.




We follow our relationships to the movies who received the, but filter out “v”
which is our starting movie. We do not want the system to recommend the
same movie we just watched.
Explanation
filter{it.out('hasGenre').toSet().equals(x)}.




We also want to keep only the movies that have the same genres as our
starting movie. People gave Toy Story and Terminator both 4 stars,
but you wouldn’t want to recommend one to the other.
Explanation
groupCount(m){"${it.id}:${it.title}"}.iterate();




groupCount does what it sounds like and stores the values in the map “m”
we created earlier, but we to retain the id and title of the movies.

iterate() is needed from the Neo4j REST API, the gremlin shell does
it automatically for you. You will forget this one day and kill
30 minutes of your life trying to figure out why you get nothing.
Explanation
m.sort{a,b -> b.value <=> a.value}[0..24]




Finally, we sort our map by value in descending order and grab the top
25 items… and you’re done.
See http://maxdemarzi.com/2012/01/16/neo4j-on-heroku-part-two/
for the full walk-through including data loading.
What is Cypher?
The blue pill after the red pill
• Graph Query language for Neo4j
• Based on Pattern Matching
• Makes querying easy again
Cypher : Neo4j Query Language




ASCII ART FTW: a--b, a-->b, a<--c
Cypher Recommends
Similar Users
Which users have rated movies that I have rated within one star of my rating?
Average Rating
What is the average rating(by similar users) of a movie not rated by me?
Movies I should see
Which movies (that I haven't seen) have been rated 4 stars or higher
by users similar to me?
Questions?




  ?
Thank you!
 http://maxdemarzi.com

More Related Content

What's hot

Intro to Neo4j with Ruby
Intro to Neo4j with RubyIntro to Neo4j with Ruby
Intro to Neo4j with Ruby
Max De Marzi
 
Neo4j Data Science Presentation
Neo4j Data Science PresentationNeo4j Data Science Presentation
Neo4j Data Science Presentation
Max De Marzi
 
Neo4j Training Cypher
Neo4j Training CypherNeo4j Training Cypher
Neo4j Training Cypher
Max De Marzi
 
Neo4j Training Introduction
Neo4j Training IntroductionNeo4j Training Introduction
Neo4j Training Introduction
Max De Marzi
 
Neo4j Training Modeling
Neo4j Training ModelingNeo4j Training Modeling
Neo4j Training Modeling
Max De Marzi
 
Intro to Neo4j 2.0
Intro to Neo4j 2.0Intro to Neo4j 2.0
Intro to Neo4j 2.0
Peter Neubauer
 
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-convertedNeo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
snehapandey01
 
The Intersection of Robotics, Search and AI with Solr, MyRobotLab, and Deep L...
The Intersection of Robotics, Search and AI with Solr, MyRobotLab, and Deep L...The Intersection of Robotics, Search and AI with Solr, MyRobotLab, and Deep L...
The Intersection of Robotics, Search and AI with Solr, MyRobotLab, and Deep L...
Lucidworks
 
Query-time Nonparametric Regression with Temporally Bounded Models - Patrick ...
Query-time Nonparametric Regression with Temporally Bounded Models - Patrick ...Query-time Nonparametric Regression with Temporally Bounded Models - Patrick ...
Query-time Nonparametric Regression with Temporally Bounded Models - Patrick ...
Lucidworks
 
Webinar: Modern Techniques for Better Search Relevance with Fusion
Webinar: Modern Techniques for Better Search Relevance with FusionWebinar: Modern Techniques for Better Search Relevance with Fusion
Webinar: Modern Techniques for Better Search Relevance with Fusion
Lucidworks
 
Neo4j Fundamentals
Neo4j FundamentalsNeo4j Fundamentals
Neo4j Fundamentals
Max De Marzi
 
Vectors in Search - Towards More Semantic Matching
Vectors in Search - Towards More Semantic MatchingVectors in Search - Towards More Semantic Matching
Vectors in Search - Towards More Semantic Matching
Simon Hughes
 
Neo4J : Introduction to Graph Database
Neo4J : Introduction to Graph DatabaseNeo4J : Introduction to Graph Database
Neo4J : Introduction to Graph Database
Mindfire Solutions
 
A NoSQL Alternative to Persisting Data in your Android Apps
A NoSQL Alternative to Persisting Data in your Android AppsA NoSQL Alternative to Persisting Data in your Android Apps
A NoSQL Alternative to Persisting Data in your Android Apps
Priya Rajagopal
 
Searching with vectors
Searching with vectorsSearching with vectors
Searching with vectors
Simon Hughes
 
Introduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4jIntroduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4j
Abdullah Hamidi
 
Cool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearchCool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearch
clintongormley
 
Graphs fun vjug2
Graphs fun vjug2Graphs fun vjug2
Graphs fun vjug2Neo4j
 
Rank by time or by relevance - Revisiting Email Search
Rank by time or by relevance - Revisiting Email SearchRank by time or by relevance - Revisiting Email Search
Rank by time or by relevance - Revisiting Email Search
David Carmel
 
Object Relational Mapping with Dapper (Micro ORM)
Object Relational Mapping with Dapper (Micro ORM)Object Relational Mapping with Dapper (Micro ORM)
Object Relational Mapping with Dapper (Micro ORM)
Muhammad Umar
 

What's hot (20)

Intro to Neo4j with Ruby
Intro to Neo4j with RubyIntro to Neo4j with Ruby
Intro to Neo4j with Ruby
 
Neo4j Data Science Presentation
Neo4j Data Science PresentationNeo4j Data Science Presentation
Neo4j Data Science Presentation
 
Neo4j Training Cypher
Neo4j Training CypherNeo4j Training Cypher
Neo4j Training Cypher
 
Neo4j Training Introduction
Neo4j Training IntroductionNeo4j Training Introduction
Neo4j Training Introduction
 
Neo4j Training Modeling
Neo4j Training ModelingNeo4j Training Modeling
Neo4j Training Modeling
 
Intro to Neo4j 2.0
Intro to Neo4j 2.0Intro to Neo4j 2.0
Intro to Neo4j 2.0
 
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-convertedNeo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
 
The Intersection of Robotics, Search and AI with Solr, MyRobotLab, and Deep L...
The Intersection of Robotics, Search and AI with Solr, MyRobotLab, and Deep L...The Intersection of Robotics, Search and AI with Solr, MyRobotLab, and Deep L...
The Intersection of Robotics, Search and AI with Solr, MyRobotLab, and Deep L...
 
Query-time Nonparametric Regression with Temporally Bounded Models - Patrick ...
Query-time Nonparametric Regression with Temporally Bounded Models - Patrick ...Query-time Nonparametric Regression with Temporally Bounded Models - Patrick ...
Query-time Nonparametric Regression with Temporally Bounded Models - Patrick ...
 
Webinar: Modern Techniques for Better Search Relevance with Fusion
Webinar: Modern Techniques for Better Search Relevance with FusionWebinar: Modern Techniques for Better Search Relevance with Fusion
Webinar: Modern Techniques for Better Search Relevance with Fusion
 
Neo4j Fundamentals
Neo4j FundamentalsNeo4j Fundamentals
Neo4j Fundamentals
 
Vectors in Search - Towards More Semantic Matching
Vectors in Search - Towards More Semantic MatchingVectors in Search - Towards More Semantic Matching
Vectors in Search - Towards More Semantic Matching
 
Neo4J : Introduction to Graph Database
Neo4J : Introduction to Graph DatabaseNeo4J : Introduction to Graph Database
Neo4J : Introduction to Graph Database
 
A NoSQL Alternative to Persisting Data in your Android Apps
A NoSQL Alternative to Persisting Data in your Android AppsA NoSQL Alternative to Persisting Data in your Android Apps
A NoSQL Alternative to Persisting Data in your Android Apps
 
Searching with vectors
Searching with vectorsSearching with vectors
Searching with vectors
 
Introduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4jIntroduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4j
 
Cool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearchCool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearch
 
Graphs fun vjug2
Graphs fun vjug2Graphs fun vjug2
Graphs fun vjug2
 
Rank by time or by relevance - Revisiting Email Search
Rank by time or by relevance - Revisiting Email SearchRank by time or by relevance - Revisiting Email Search
Rank by time or by relevance - Revisiting Email Search
 
Object Relational Mapping with Dapper (Micro ORM)
Object Relational Mapping with Dapper (Micro ORM)Object Relational Mapping with Dapper (Micro ORM)
Object Relational Mapping with Dapper (Micro ORM)
 

Viewers also liked

Graph Based Recommendation Systems at eBay
Graph Based Recommendation Systems at eBayGraph Based Recommendation Systems at eBay
Graph Based Recommendation Systems at eBay
DataStax Academy
 
Neo4j in Depth
Neo4j in DepthNeo4j in Depth
Neo4j in Depth
Max De Marzi
 
Recommender system algorithm and architecture
Recommender system algorithm and architectureRecommender system algorithm and architecture
Recommender system algorithm and architectureLiang Xiang
 
Intro to Mutating Cypher
Intro to Mutating CypherIntro to Mutating Cypher
Intro to Mutating CypherMax De Marzi
 
Data 2.0
Data 2.0 Data 2.0
Data 2.0
Max De Marzi
 
Visualizing your Graph
Visualizing your GraphVisualizing your Graph
Visualizing your GraphMax De Marzi
 
Analysing Large Citation Network
Analysing Large Citation NetworkAnalysing Large Citation Network
Analysing Large Citation Network
Milad Alshomary
 
What Finance can learn from Dating Sites
What Finance can learn from Dating SitesWhat Finance can learn from Dating Sites
What Finance can learn from Dating Sites
Max De Marzi
 
Session 1 & 2 introduction & evolution
Session 1 & 2 introduction & evolutionSession 1 & 2 introduction & evolution
Session 1 & 2 introduction & evolutionDelwin Arikatt
 
150921 recommendation splendid-praesentation
150921 recommendation splendid-praesentation150921 recommendation splendid-praesentation
150921 recommendation splendid-praesentation
Splendid Internet GmbH
 
Integrated Strategies for Customer Loyalty and Value Optimization
Integrated Strategies for Customer Loyalty and Value OptimizationIntegrated Strategies for Customer Loyalty and Value Optimization
Integrated Strategies for Customer Loyalty and Value OptimizationVivastream
 
People supply chain for knowledge based organizations
People supply chain for knowledge based organizationsPeople supply chain for knowledge based organizations
People supply chain for knowledge based organizationsRavi Tirumalai
 
Business use of Social Media and Impact on Enterprise Architecture
Business use of Social Media and Impact on Enterprise ArchitectureBusiness use of Social Media and Impact on Enterprise Architecture
Business use of Social Media and Impact on Enterprise Architecture
NUS-ISS
 
Flexible recommender systems based on graphs
Flexible recommender systems based on graphsFlexible recommender systems based on graphs
Flexible recommender systems based on graphs
recsysfr
 
Book Recommendation System using Data Mining for the University of Hong Kong ...
Book Recommendation System using Data Mining for the University of Hong Kong ...Book Recommendation System using Data Mining for the University of Hong Kong ...
Book Recommendation System using Data Mining for the University of Hong Kong ...
CITE
 
Bibliometric network analysis: Software tools, techniques, and an analysis o...
Bibliometric network analysis: Software tools, techniques, and an analysis o...Bibliometric network analysis: Software tools, techniques, and an analysis o...
Bibliometric network analysis: Software tools, techniques, and an analysis o...
Nees Jan van Eck
 
Design of recommender systems
Design of recommender systemsDesign of recommender systems
Design of recommender systemsRashmi Sinha
 
Operational, Analytical & Collaborative Crm
Operational, Analytical & Collaborative CrmOperational, Analytical & Collaborative Crm
Operational, Analytical & Collaborative Crm
Elijah Ezendu
 

Viewers also liked (20)

Graph Based Recommendation Systems at eBay
Graph Based Recommendation Systems at eBayGraph Based Recommendation Systems at eBay
Graph Based Recommendation Systems at eBay
 
Neo4j in Depth
Neo4j in DepthNeo4j in Depth
Neo4j in Depth
 
Recommender system algorithm and architecture
Recommender system algorithm and architectureRecommender system algorithm and architecture
Recommender system algorithm and architecture
 
Intro to Mutating Cypher
Intro to Mutating CypherIntro to Mutating Cypher
Intro to Mutating Cypher
 
Data 2.0
Data 2.0 Data 2.0
Data 2.0
 
Visualizing your Graph
Visualizing your GraphVisualizing your Graph
Visualizing your Graph
 
Analysing Large Citation Network
Analysing Large Citation NetworkAnalysing Large Citation Network
Analysing Large Citation Network
 
What Finance can learn from Dating Sites
What Finance can learn from Dating SitesWhat Finance can learn from Dating Sites
What Finance can learn from Dating Sites
 
Recommendation Engine Demystified
Recommendation Engine DemystifiedRecommendation Engine Demystified
Recommendation Engine Demystified
 
Session 1 & 2 introduction & evolution
Session 1 & 2 introduction & evolutionSession 1 & 2 introduction & evolution
Session 1 & 2 introduction & evolution
 
150921 recommendation splendid-praesentation
150921 recommendation splendid-praesentation150921 recommendation splendid-praesentation
150921 recommendation splendid-praesentation
 
Integrated Strategies for Customer Loyalty and Value Optimization
Integrated Strategies for Customer Loyalty and Value OptimizationIntegrated Strategies for Customer Loyalty and Value Optimization
Integrated Strategies for Customer Loyalty and Value Optimization
 
People supply chain for knowledge based organizations
People supply chain for knowledge based organizationsPeople supply chain for knowledge based organizations
People supply chain for knowledge based organizations
 
Business use of Social Media and Impact on Enterprise Architecture
Business use of Social Media and Impact on Enterprise ArchitectureBusiness use of Social Media and Impact on Enterprise Architecture
Business use of Social Media and Impact on Enterprise Architecture
 
Flexible recommender systems based on graphs
Flexible recommender systems based on graphsFlexible recommender systems based on graphs
Flexible recommender systems based on graphs
 
Book Recommendation System using Data Mining for the University of Hong Kong ...
Book Recommendation System using Data Mining for the University of Hong Kong ...Book Recommendation System using Data Mining for the University of Hong Kong ...
Book Recommendation System using Data Mining for the University of Hong Kong ...
 
Bibliometric network analysis: Software tools, techniques, and an analysis o...
Bibliometric network analysis: Software tools, techniques, and an analysis o...Bibliometric network analysis: Software tools, techniques, and an analysis o...
Bibliometric network analysis: Software tools, techniques, and an analysis o...
 
Design of recommender systems
Design of recommender systemsDesign of recommender systems
Design of recommender systems
 
Crm new1
Crm new1Crm new1
Crm new1
 
Operational, Analytical & Collaborative Crm
Operational, Analytical & Collaborative CrmOperational, Analytical & Collaborative Crm
Operational, Analytical & Collaborative Crm
 

Similar to Windy City DB - Recommendation Engine with Neo4j

Hands on Training – Graph Database with Neo4j
Hands on Training – Graph Database with Neo4jHands on Training – Graph Database with Neo4j
Hands on Training – Graph Database with Neo4j
Serendio Inc.
 
Recommendations with Neo4j (FOSDEM 2015)
Recommendations with Neo4j (FOSDEM 2015)Recommendations with Neo4j (FOSDEM 2015)
Recommendations with Neo4j (FOSDEM 2015)
GraphAware
 
Processing Large Graphs
Processing Large GraphsProcessing Large Graphs
Processing Large Graphs
Nishant Gandhi
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scala
tod esking
 
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
GreeceJS
 
03 introduction to graph databases
03   introduction to graph databases03   introduction to graph databases
03 introduction to graph databases
Neo4j
 
networkanalysis
networkanalysisnetworkanalysis
networkanalysismoogway
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
Skills Matter
 
Software Architecture: Principles, Patterns and Practices
Software Architecture: Principles, Patterns and PracticesSoftware Architecture: Principles, Patterns and Practices
Software Architecture: Principles, Patterns and Practices
Ganesh Samarthyam
 
Application Modeling with Graph Databases
Application Modeling with Graph DatabasesApplication Modeling with Graph Databases
Application Modeling with Graph DatabasesJosh Adell
 
Creating Custom Charts With Ruby Vector Graphics
Creating Custom Charts With Ruby Vector GraphicsCreating Custom Charts With Ruby Vector Graphics
Creating Custom Charts With Ruby Vector Graphics
David Keener
 
Big Data Expo 2015 - Hortonworks Effective use of Apache Spark
Big Data Expo 2015 - Hortonworks Effective use of Apache SparkBig Data Expo 2015 - Hortonworks Effective use of Apache Spark
Big Data Expo 2015 - Hortonworks Effective use of Apache Spark
BigDataExpo
 
An Empirical Comparison of Knowledge Graph Embeddings for Item Recommendation
An Empirical Comparison of Knowledge Graph Embeddings for Item RecommendationAn Empirical Comparison of Knowledge Graph Embeddings for Item Recommendation
An Empirical Comparison of Knowledge Graph Embeddings for Item Recommendation
Enrico Palumbo
 
What the C?
What the C?What the C?
What the C?
baccigalupi
 
Decision Tree.pptx
Decision Tree.pptxDecision Tree.pptx
Decision Tree.pptx
Ramakrishna Reddy Bijjam
 
Introduction to Graphs with Neo4j
Introduction to Graphs with Neo4jIntroduction to Graphs with Neo4j
Introduction to Graphs with Neo4j
Neo4j
 
Mongo db queries
Mongo db queriesMongo db queries
Mongo db queries
ssuser6d5faa
 
wwc start-launched
wwc start-launchedwwc start-launched
wwc start-launchedMat Schaffer
 
Information from pixels
Information from pixelsInformation from pixels
Information from pixels
Dave Snowdon
 

Similar to Windy City DB - Recommendation Engine with Neo4j (20)

Hands on Training – Graph Database with Neo4j
Hands on Training – Graph Database with Neo4jHands on Training – Graph Database with Neo4j
Hands on Training – Graph Database with Neo4j
 
Recommendations with Neo4j (FOSDEM 2015)
Recommendations with Neo4j (FOSDEM 2015)Recommendations with Neo4j (FOSDEM 2015)
Recommendations with Neo4j (FOSDEM 2015)
 
Processing Large Graphs
Processing Large GraphsProcessing Large Graphs
Processing Large Graphs
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scala
 
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
 
03 introduction to graph databases
03   introduction to graph databases03   introduction to graph databases
03 introduction to graph databases
 
networkanalysis
networkanalysisnetworkanalysis
networkanalysis
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
Software Architecture: Principles, Patterns and Practices
Software Architecture: Principles, Patterns and PracticesSoftware Architecture: Principles, Patterns and Practices
Software Architecture: Principles, Patterns and Practices
 
Application Modeling with Graph Databases
Application Modeling with Graph DatabasesApplication Modeling with Graph Databases
Application Modeling with Graph Databases
 
Creating Custom Charts With Ruby Vector Graphics
Creating Custom Charts With Ruby Vector GraphicsCreating Custom Charts With Ruby Vector Graphics
Creating Custom Charts With Ruby Vector Graphics
 
Big Data Expo 2015 - Hortonworks Effective use of Apache Spark
Big Data Expo 2015 - Hortonworks Effective use of Apache SparkBig Data Expo 2015 - Hortonworks Effective use of Apache Spark
Big Data Expo 2015 - Hortonworks Effective use of Apache Spark
 
An Empirical Comparison of Knowledge Graph Embeddings for Item Recommendation
An Empirical Comparison of Knowledge Graph Embeddings for Item RecommendationAn Empirical Comparison of Knowledge Graph Embeddings for Item Recommendation
An Empirical Comparison of Knowledge Graph Embeddings for Item Recommendation
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
What the C?
What the C?What the C?
What the C?
 
Decision Tree.pptx
Decision Tree.pptxDecision Tree.pptx
Decision Tree.pptx
 
Introduction to Graphs with Neo4j
Introduction to Graphs with Neo4jIntroduction to Graphs with Neo4j
Introduction to Graphs with Neo4j
 
Mongo db queries
Mongo db queriesMongo db queries
Mongo db queries
 
wwc start-launched
wwc start-launchedwwc start-launched
wwc start-launched
 
Information from pixels
Information from pixelsInformation from pixels
Information from pixels
 

More from Max De Marzi

DataDay 2023 Presentation
DataDay 2023 PresentationDataDay 2023 Presentation
DataDay 2023 Presentation
Max De Marzi
 
DataDay 2023 Presentation - Notes
DataDay 2023 Presentation - NotesDataDay 2023 Presentation - Notes
DataDay 2023 Presentation - Notes
Max De Marzi
 
Developer Intro Deck-PowerPoint - Download for Speaker Notes
Developer Intro Deck-PowerPoint - Download for Speaker NotesDeveloper Intro Deck-PowerPoint - Download for Speaker Notes
Developer Intro Deck-PowerPoint - Download for Speaker Notes
Max De Marzi
 
Outrageous Ideas for Graph Databases
Outrageous Ideas for Graph DatabasesOutrageous Ideas for Graph Databases
Outrageous Ideas for Graph Databases
Max De Marzi
 
Detenga el fraude complejo con Neo4j
Detenga el fraude complejo con Neo4jDetenga el fraude complejo con Neo4j
Detenga el fraude complejo con Neo4j
Max De Marzi
 
Data Modeling Tricks for Neo4j
Data Modeling Tricks for Neo4jData Modeling Tricks for Neo4j
Data Modeling Tricks for Neo4j
Max De Marzi
 
Fraud Detection and Neo4j
Fraud Detection and Neo4j Fraud Detection and Neo4j
Fraud Detection and Neo4j
Max De Marzi
 
Detecion de Fraude con Neo4j
Detecion de Fraude con Neo4jDetecion de Fraude con Neo4j
Detecion de Fraude con Neo4j
Max De Marzi
 
Neo4j Stored Procedure Training Part 2
Neo4j Stored Procedure Training Part 2Neo4j Stored Procedure Training Part 2
Neo4j Stored Procedure Training Part 2
Max De Marzi
 
Neo4j Stored Procedure Training Part 1
Neo4j Stored Procedure Training Part 1Neo4j Stored Procedure Training Part 1
Neo4j Stored Procedure Training Part 1
Max De Marzi
 
Decision Trees in Neo4j
Decision Trees in Neo4jDecision Trees in Neo4j
Decision Trees in Neo4j
Max De Marzi
 
Neo4j y Fraude Spanish
Neo4j y Fraude SpanishNeo4j y Fraude Spanish
Neo4j y Fraude Spanish
Max De Marzi
 
Fraud Detection Class Slides
Fraud Detection Class SlidesFraud Detection Class Slides
Fraud Detection Class Slides
Max De Marzi
 
Graph database Use Cases
Graph database Use CasesGraph database Use Cases
Graph database Use Cases
Max De Marzi
 
Introduction to Gremlin
Introduction to GremlinIntroduction to Gremlin
Introduction to GremlinMax De Marzi
 

More from Max De Marzi (15)

DataDay 2023 Presentation
DataDay 2023 PresentationDataDay 2023 Presentation
DataDay 2023 Presentation
 
DataDay 2023 Presentation - Notes
DataDay 2023 Presentation - NotesDataDay 2023 Presentation - Notes
DataDay 2023 Presentation - Notes
 
Developer Intro Deck-PowerPoint - Download for Speaker Notes
Developer Intro Deck-PowerPoint - Download for Speaker NotesDeveloper Intro Deck-PowerPoint - Download for Speaker Notes
Developer Intro Deck-PowerPoint - Download for Speaker Notes
 
Outrageous Ideas for Graph Databases
Outrageous Ideas for Graph DatabasesOutrageous Ideas for Graph Databases
Outrageous Ideas for Graph Databases
 
Detenga el fraude complejo con Neo4j
Detenga el fraude complejo con Neo4jDetenga el fraude complejo con Neo4j
Detenga el fraude complejo con Neo4j
 
Data Modeling Tricks for Neo4j
Data Modeling Tricks for Neo4jData Modeling Tricks for Neo4j
Data Modeling Tricks for Neo4j
 
Fraud Detection and Neo4j
Fraud Detection and Neo4j Fraud Detection and Neo4j
Fraud Detection and Neo4j
 
Detecion de Fraude con Neo4j
Detecion de Fraude con Neo4jDetecion de Fraude con Neo4j
Detecion de Fraude con Neo4j
 
Neo4j Stored Procedure Training Part 2
Neo4j Stored Procedure Training Part 2Neo4j Stored Procedure Training Part 2
Neo4j Stored Procedure Training Part 2
 
Neo4j Stored Procedure Training Part 1
Neo4j Stored Procedure Training Part 1Neo4j Stored Procedure Training Part 1
Neo4j Stored Procedure Training Part 1
 
Decision Trees in Neo4j
Decision Trees in Neo4jDecision Trees in Neo4j
Decision Trees in Neo4j
 
Neo4j y Fraude Spanish
Neo4j y Fraude SpanishNeo4j y Fraude Spanish
Neo4j y Fraude Spanish
 
Fraud Detection Class Slides
Fraud Detection Class SlidesFraud Detection Class Slides
Fraud Detection Class Slides
 
Graph database Use Cases
Graph database Use CasesGraph database Use Cases
Graph database Use Cases
 
Introduction to Gremlin
Introduction to GremlinIntroduction to Gremlin
Introduction to Gremlin
 

Recently uploaded

Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 

Recently uploaded (20)

Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 

Windy City DB - Recommendation Engine with Neo4j

  • 1. Adding a Recommendation Engine WindyCityDB Max De Marzi
  • 2. About Me Built the Neography Gem (Ruby Wrapper to the Neo4j REST API) Playing with Neo4j since 10/2009 • My Blog: http://maxdemarzi.com • Find me on Twitter: @maxdemarzi • Email me: maxdemarzi@gmail.com • GitHub: http://github.com/maxdemarzi
  • 3. Agenda • What is Neo4j? • What is Neography? • Approaches • Gremlin • Gremlin Recommends • Cypher • Cypher Recommends
  • 4. What is Neo4j? • A Graph Database + Lucene Index • Property Graph • Full ACID (atomicity, consistency, isolation, durability) • High Availability (with Enterprise Edition) • 32 Billion Nodes, 32 Billion Relationships, 64 Billion Properties • Embedded Server (Java or JVM languages) • REST API (for everyone else)
  • 5. Obligatory CAP theorem Slide • Neo4j is at the section joining Consistency with Availability just like your RDBMS
  • 6. Good For • Highly connected data (social networks) • Recommendations (e-commerce) • Path Finding (how do I know you?) • A* (Least Cost path) • Data First Schema (bottom-up, but you still need to design)
  • 8. If you’ve ever • Joined more than 7 tables together • Modeled a graph in a table • Written a recursive CTE • Tried to write some crazy stored procedure with multiple recursive self and inner joins You should use Neo4j
  • 10. A very thin wrapper to the Neo4j REST API • Two layers: Following the REST API Ruby Sugar • Made for graph database programmer happiness >8-] • Read the github Readme and Specs • Can I haz pull requests? • Want Active Record? Use the activerecord-neo4j-adapter gem which sits on top of neography
  • 11. How do I install Neo4j? Create a project directory and do this now if you haven’t yet. Make sure wget is installed.
  • 13. Collaborative Filtering • Step 1: Collect User Behavior • Step 2: Find similar Users • Step 3: Recommend Behavior taken by similar users
  • 14. Content Based Filtering • Step 1: Collect Item Characteristics • Step 2: Find similar Items • Step 3: Recommend Similar Items Marko likes Romantic Zombie Comedies, what other romantic zombie comedies are there? Tweet him @twarko
  • 15. Hybrid • Combine the two for better results. • Example: Netflix
  • 17. Gremlin is • A Graph Traversal Language • A domain specific language for traversing property graphs • Implemented by most Graph Database Vendors • Primarily seen with the Groovy Language • With JVM connectivity in Java, Scala, and other languages
  • 19. A Graph DSL A Dynamic Language for the JVM A Data Flow Framework “JDBC” for Graph DBs
  • 22. Our Graph (from MovieLens)
  • 23. Recommendation Algorithm m = [:]; x = [] as Set; (continued) v = g.v(node_id); outV. outE('rated'). v. filter{it.stars > 3}. out('hasGenre'). inV. aggregate(x). filter{it != v}. back(2). filter{it.out('hasGenre').toSet().equals(x)}. inE('rated'). groupCount(m){"${it.id}:${it.title}"}.iterate(); filter{it. stars > 3}. m.sort{a,b -> b.value <=> a.value}[0..24]
  • 24. Explanation m = [:]; x = [] as Set; v = g.v(node_id); In Groovy [:] is a map, we will return this The set “x” will hold the collection of genres we want our recommended movies to have. v is our starting point.
  • 25. Explanation v. out('hasGenre'). (we are now at a genre node) aggregate(x). We fill the empty set “x” with the genres of our movie. These are the properties we want to make sure our recommendations have.
  • 26. Explanation back(2). (we are back to our starting point) inE('rated'). filter{it. stars > 3}. (we are now at the link between our movie and users) We go back two steps to our starting movie, go to the relationship ‘rated’ and filter it so we only keep those with more than 3 stars.
  • 27. Explanation outV. (we are now at a user node) outE('rated'). filter{it.stars > 3}. (we are now at the link between user and movie) We follow our relationships to the users who made them, and then go to the “rated” relationships of movies which also received more than 3 stars.
  • 28. Explanation inV. (we are now at a movie node) filter{it != v}. We follow our relationships to the movies who received the, but filter out “v” which is our starting movie. We do not want the system to recommend the same movie we just watched.
  • 29. Explanation filter{it.out('hasGenre').toSet().equals(x)}. We also want to keep only the movies that have the same genres as our starting movie. People gave Toy Story and Terminator both 4 stars, but you wouldn’t want to recommend one to the other.
  • 30. Explanation groupCount(m){"${it.id}:${it.title}"}.iterate(); groupCount does what it sounds like and stores the values in the map “m” we created earlier, but we to retain the id and title of the movies. iterate() is needed from the Neo4j REST API, the gremlin shell does it automatically for you. You will forget this one day and kill 30 minutes of your life trying to figure out why you get nothing.
  • 31. Explanation m.sort{a,b -> b.value <=> a.value}[0..24] Finally, we sort our map by value in descending order and grab the top 25 items… and you’re done. See http://maxdemarzi.com/2012/01/16/neo4j-on-heroku-part-two/ for the full walk-through including data loading.
  • 33. The blue pill after the red pill • Graph Query language for Neo4j • Based on Pattern Matching • Makes querying easy again
  • 34. Cypher : Neo4j Query Language ASCII ART FTW: a--b, a-->b, a<--c
  • 36. Similar Users Which users have rated movies that I have rated within one star of my rating?
  • 37. Average Rating What is the average rating(by similar users) of a movie not rated by me?
  • 38. Movies I should see Which movies (that I haven't seen) have been rated 4 stars or higher by users similar to me?

Editor's Notes

  1. Atomic = all or nothing, consistent = stay consistent from one tx to another, isolation = no tx will mess with another tx, durability = once tx committed, it stays