Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

GraphTour Boston - Graphs for AI and ML

104 views

Published on

Presentation from Neo4j GraphTour Boston held October 22 - Graphs for AI and ML - Jim Webber, Chief Scientist, Neo4j

Published in: Business
  • Today's dogs suffer from a lack of mental stimulation and quality time spent with "their" people. The resulting boredom and anxiety can lead to no end of physical and behavioral problems. Brain Training for Dogs is the solution! In a clear and concise manner, Adrienne Farricelli walks owners through a series of puzzles and exercises that will challenge and entertain dogs of all abilities. ●●● http://ishbv.com/brainydogs/pdf
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

GraphTour Boston - Graphs for AI and ML

  1. 1. Graphs for AI and ML Dr. Jim Webber Chief Scientist, Neo4j @jimwebber
  2. 2. ● Some no-BS definitions ● Graphs and an accidental Skynet ● Graph theory ● Contemporary graph ML ● The future of graph AI Overview
  3. 3. ● ML - Machine Learning ○ Finding functions from historical data to guide future interactions within a given domain ● AI - Artificial Intelligence ● The property of a system that it appears intelligent to its users ● Often, but not always, using ML techniques ● Or ML implementations that can be cheaply retrained to address neighboring domains A Bluffer’s Guide to AI-cronyms
  4. 4. ● Predictive analytics ● Use past data to predict the future ● General purpose AI ● ML with transfer learning such that learned experiences in one domain can be applied elsewhere ● Human-like AI Often conflated with
  5. 5. ML all the things What we do today
  6. 6. Extract all the features! • What do we do? Turn it to vectors and pump it through a classification or regression model • That’s actually not a bad thing • But we can do so much before we even get to ML… • … if we have graph data
  7. 7. Credit: Graph Algorithms, Holder and Needham, O’Reilly 2019
  8. 8. http://www.bbc.co.uk/london/travel/downloads/tube_map.html
  9. 9. • Nodes with optional properties and optional labels • Named, directed relationships with optional properties • Relationships have exactly one start and end node • Which may be the same node Labeled Property graph model
  10. 10. stole from loves loves enemy enemy A Good Man Goes to War appeared in appeared in appeared in appeared in Victory of the Daleks appeared in appeared in companion companion enemy
  11. 11. stole from loves loves enemy enemy A Good Man Goes to War appeared in appeared in appeared in appeared in Victory of the Daleks appeared in appeared in companion companion enemy planet prop species species species character character character episode episode
  12. 12. R..ted R..ted
  13. 13. R..ted R..ted R..ted
  14. 14. Fearless querying MATCH path = (:author {name:’Jim Webber’} -[*]->(:character {name:’The Doctor’}) RETURN path OR MATCH (me:author {name:’Jim Webber’}, (doc:character {name:’The Doctor’}), path = shortestPath((me)-[*]->(doc)) RETURN path
  15. 15. regeneration character actor character actor landlord author tenant flat book author owns sublet series character
  16. 16. Take a step back We can be smarter about this
  17. 17. Realtime Predictive Analytics (circa 2008) + + =
  18. 18. Not AI, but extremely effective Credit: https://medium.com/basecs/breaking-down-breadth-first-search-cebe696709d9
  19. 19. Credit: https://www.networkworld.com/article/3211410 /lan-wan/the-10-most-powerful-companies-in- enterprise-networking.html
  20. 20. Toolkit matures into proper database • Cypher and Neo4j server make real time graph analytical patterns simple to apply • Amazing and humane to implement
  21. 21. Firstname: Mickey Surname: Smith DoB: 19781006 SKU: 5e175641 Product: Badgers Nadgers Ale SKU: 2555f258 Product: Peewee Pilsner Category: beer SKU: 49d102bc Product: Baby Dry Nights Category: nappies Category: baby Category: alcoholic drinks SKU: 49d102bc Product: XBox 360 Category: consumer electronics Category: console BOUGHTBOUGHT MEMBER_OF MEMBER_OFMEMBER_OF MEMBER_OFMEMBER_OF
  22. 22. Firstname: * Surname: * DoB: 1996 > x > 1972 Category: beerCategory: nappies BOUGHTCategory: game console Young fathers pattern
  23. 23. Firstname: * Surname: * DoB: 1996 > x > 1972 Category: beerCategory: nappies !BOUGHTCategory: game console Business opportunity
  24. 24. (beer)(nappies) (console) (daddy) () () ()
  25. 25. (d)-[:BOUGHT]->()-[:MEMBER_OF]->(n) (d)-[:BOUGHT]->()-[:MEMBER_OF]->(b) (d)-[:BOUGHT]->()-[:MEMBER_OF]->(c) Flatten the graph
  26. 26. (d:Person)-[:BOUGHT]->()-[:MEMBER_OF]->(n:Category) (d:Person)-[:BOUGHT]->()-[:MEMBER_OF]->(b:Category) (d:Person)-[:BOUGHT]->()-[:MEMBER_OF]->(c:Category) Include any labels
  27. 27. MATCH (d:Person)-[:BOUGHT]->()-[:MEMBER_OF]->(n:Category), (d:Person)-[:BOUGHT]->()-[:MEMBER_OF]->(b:Category) Add a MATCH clause
  28. 28. MATCH (d:Person)-[:BOUGHT]->()-[:MEMBER_OF]->(n:Category), (d:Person)-[:BOUGHT]->()-[:MEMBER_OF]->(b:Category), (c:Category) WHERE NOT((d)-[:BOUGHT]->()-[:MEMBER_OF]->(c)) Constrain the Pattern
  29. 29. MATCH (d:Person)-[:BOUGHT]->()-[:MEMBER_OF]->(n:Category), (d:Person)-[:BOUGHT]->()-[:MEMBER_OF]->(b:Category), (c:Category) WHERE n.category = "nappies" AND b.category = "beer" AND c.category = "console" AND NOT((d)-[:BOUGHT]->()-[:MEMBER_OF]->(c)) Add property constraints
  30. 30. MATCH (d:Person)-[:BOUGHT]->()-[:MEMBER_OF]->(n:Category), (d:Person)-[:BOUGHT]->()-[:MEMBER_OF]->(b:Category), (c:Category) WHERE n.category = "nappies" AND b.category = "beer" AND c.category = "console" AND NOT((d)-[:BOUGHT]->()-[:MEMBER_OF]->(c)) RETURN DISTINCT d AS daddy Profit!
  31. 31. ==> +---------------------------------------------+ ==> | daddy | ==> +---------------------------------------------+ ==> | Node[15]{name:"Rory Williams",dob:19880121} | ==> +---------------------------------------------+ ==> 1 row ==> 0 ms ==> neo4j-sh (0)$ Results
  32. 32. Which sushi restaurants in NYC do my friends like? Facebook Graph Search See http://maxdemarzi.com/
  33. 33. Graph Structure
  34. 34. Simple Query, Intelligent Results MATCH (:Person {name: 'Jim'}) -[:IS_FRIEND_OF]->(:Person) -[:LIKES]->(restaurant:Restaurant) -[:LOCATED_IN]->(:Place {location: 'New York'}), (restaurant)-[:SERVES]->(:Cuisine {cuisine: 'Sushi'}) RETURN restaurant
  35. 35. Search structure
  36. 36. Graph Theory • Rich knowledge of how graphs operate in many domains • Off the shelf algorithms to process those graphs for information, insight, predictions • Low barrier to entry • Amazingly powerful
  37. 37. Triadic Closure name: Kyle name: Stan name: Kenny
  38. 38. Triadic Closure name: Kyle name: Stan name: Kenny name: Kyle name: Stan name: Kenny FRIEND
  39. 39. Structural Balance name: Cartman name: Craig name: Tweek
  40. 40. Structural Balance name: Cartman name: Craig name: Tweek name: Cartman name: Craig name: Tweek FRIEND
  41. 41. Structural Balance name: Cartman name: Craig name: Tweek name: Cartman name: Craig name: Tweek ENEMY
  42. 42. Structural Balance name: Kyle name: Stan name: Kenny name: Kyle name: Stan name: Kenny FRIEND
  43. 43. Structural Balance is a key predictive technique And it’s domain-agnostic
  44. 44. Allies and Enemies UK GermanyFrance Russia Italy Austria
  45. 45. Allies and Enemies UK GermanyFrance Russia Italy Austria
  46. 46. Allies and Enemies UK GermanyFrance Russia Italy Austria
  47. 47. Allies and Enemies UK GermanyFrance Russia Italy Austria
  48. 48. Allies and Enemies UK GermanyFrance Russia Italy Austria
  49. 49. Allies and Enemies UK GermanyFrance Russia Italy Austria
  50. 50. Predicting WWI [Easley and Kleinberg]
  51. 51. It if a node has strong relationships to two neighbours, then these neighbours must have at least a weak relationship between them. [Wikipedia] Strong Triadic Closure
  52. 52. Triadic Closure (weak relationship) name: Kenny name: Stan name: Cartman
  53. 53. Triadic Closure (weak relationship) name: Kenny name: Stan name: Cartman name: Kenny name: Stan name: Cartman FRIEND 50%
  54. 54. • Relationships can have “strength” as well as intent • Think: weighting on a relationship in a property graph • Weak links play another super-important structural role in graph theory • They bridge neighbourhoods Weak relationships
  55. 55. Local Bridges FRIEND name: Kenny name: Stanname: Kyle FRIEND FRIEND name: Sally name: Bebename: Wendy FRIEND FRIEND 50% name: Cartman FRIEND ENEMY
  56. 56. “If a node A in a network satisfies the Strong Triadic Closure Property and is involved in at least two strong relationships, then any local bridge it is involved in must be a weak relationship.” [Easley and Kleinberg] Local Bridge Property
  57. 57. University Karate Club
  58. 58. • (NP) Hard problem • Repeatedly remove the spanning links between dense regions • Or recursively merge nodes into ever larger “subgraph” nodes • Choose your algorithm carefully – some are better than others for a given domain • Can use to (almost exactly) predict the break up of the karate club! Graph Partitioning
  59. 59. University Karate Clubs (predicted by Graph Theory) 9
  60. 60. University Karate Clubs (what actually happened!)
  61. 61. • Label Propagation • Union Find / Weakly Connected Components • Strongly Connected Components • Triangle-Count / Clustering Coefficient ClusteringCentrality • PageRank • Betweenness • Closeness • Degree Path Finding • Breadth-first search • Depth-first search • Single-source shortest path • All-pairs shortest path • Minimum weight spanning tree Graph Algorithms in Neo4j
  62. 62. Amazing Native Graph Performance
  63. 63. Credit: https://reezocar.blob.core.windows.net/blog/2015/09/k2000.jpg
  64. 64. Find and stop spammers Extract graph structure over time Not message content! (Fakhraei et al, KDD 2015) Learning to stop bad guys Result: find and classify 70% spammers with 90% accuracy
  65. 65. Much of modern graph ML is still about turning graphs to vectors Graph2Vec and friends Highly complementary techniques Mixing structural data and features gives better results Better data into the model, better results out But we don’t have to always vectorize graphs... Graph ML
  66. 66. Knowledge Graphs • Semantic domain knowledge for inference and understanding • E.g. eBay Google Assistant • What’s the next best question to ask when a potential customer says they want a bag? • Price? Function? Colour? • Depends on context! Demographic, history, user journey. • Richly connected data makes the system seem intelligent • But it’s “just” data and algorithms in reality
  67. 67. Graph Convolutional Neural Networks A general architecture for predicting node and relationship attributes in graphs. (Kipf and Welling, ICLR 2017) Credit: Andrew Docherty (CSIRO), YowData 2017 https://www.youtube.com/watch?v=Gmxz41L70Fg
  68. 68. Graph Networks for Structured Causal Models • Position paper from Google, MIT, Edinburgh • Structured representations and computations (graphs) are key • Goal: generalize beyond direct experience • Like human infants can https://arxiv.org/pdf/1806.01261.pdf
  69. 69. credit: @markhneedham
  70. 70. Thanks for listening Dr. Jim Webber Chief Scientist, Neo4j @jimwebber

×