transforming your data: a worked example

97
09:00-09:30 09:30-10:15 10:15-11:00 11:00-11:30 11:30-12:30 12:30-13:30 13:30-17:00 Breakfast and Registration The Connected Data Imperative: Why Graphs Transform Your Data: A Worked Example Break Enterprise Ready: A Look at Neo4j in Production Lunch Hands-On Training Session Agenda APRIL 26, 2017 SANTA CLARA

Upload: neo4j-the-fastest-and-most-scalable-native-graph-database

Post on 23-Jan-2018

153 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Transforming Your Data: A Worked Example

09:00-09:30 09:30-10:15

10:15-11:00 11:00-11:30 11:30-12:30

12:30-13:30 13:30-17:00

Breakfast and RegistrationThe Connected Data Imperative: Why Graphs

Transform Your Data: A Worked ExampleBreakEnterprise Ready: A Look at Neo4j in Production LunchHands-On Training Session

Agenda

APRIL 26, 2017SANTA CLARA

Page 2: Transforming Your Data: A Worked Example

Transform Your Data

Neo4j Graph Day - Santa Clara 2017William Lyon@lyonwj

A Worked Example

Page 3: Transforming Your Data: A Worked Example

William LyonDeveloper Relations Engineer @neo4j

[email protected] @lyonwj lyonwj.com

Page 4: Transforming Your Data: A Worked Example

Agenda

• Graph database - developer perspective• (relational)-[:TO]->(graph)• Use cases• Fraud Detection• Recommendations

• Developer tooling

Page 5: Transforming Your Data: A Worked Example

Neo4j

Graph Database

• Property graph data model• (open)Cypher query language• Native graph processing• Language drivers• Open source

neo4j.com

Page 6: Transforming Your Data: A Worked Example

Graph Data Model

Page 7: Transforming Your Data: A Worked Example

Labeled Property Graph Model

Page 8: Transforming Your Data: A Worked Example

Labeled Property Graph Model

Page 9: Transforming Your Data: A Worked Example

The Graph

https://github.com/johnymontana/neo4j-datasets/tree/master/yelp

Page 10: Transforming Your Data: A Worked Example

The Graph

https://www.youtube.com/watch?v=kSZHFlBDIfM

Page 11: Transforming Your Data: A Worked Example

The Graph

https://github.com/johnymontana/mattermark-graphql-neo4j

Page 12: Transforming Your Data: A Worked Example

The Graph

https://github.com/neo4j-meetups/modeling-worked-example

Page 13: Transforming Your Data: A Worked Example

The Graph

https://neo4j.com/sandbox-v2/

Page 14: Transforming Your Data: A Worked Example
Page 15: Transforming Your Data: A Worked Example

openCypher

(queryLanguage)-[:FOR]->(graphs)

http://www.opencypher.org/

Page 16: Transforming Your Data: A Worked Example

Cypher

Page 17: Transforming Your Data: A Worked Example

https://neo4j.com/sandbox-v2/

Page 18: Transforming Your Data: A Worked Example

Use Case: Fraud Detection

Page 19: Transforming Your Data: A Worked Example

Organized in groups Synthetic Identities Stolen Identities Hijacked Devices

Who Are Today’s Fraudsters?

Page 20: Transforming Your Data: A Worked Example

Fraud Rings and Synthetic Identities

Page 21: Transforming Your Data: A Worked Example

ACCOUNT HOLDER 2

Modeling a fraud ring as a graph

ACCOUNT HOLDER 1

ACCOUNT HOLDER 3

Page 22: Transforming Your Data: A Worked Example

ACCOUNT HOLDER 2

ACCOUNT HOLDER 1

ACCOUNT HOLDER 3

CREDIT CARD

BANKACCOUNT

BANKACCOUNT

BANKACCOUNT

PHONE NUMBER

UNSECURED LOAN

SSN 2

UNSECURED LOAN

Modeling a fraud ring as a graph

Page 23: Transforming Your Data: A Worked Example

ACCOUNT HOLDER 2

ACCOUNT HOLDER 1

ACCOUNT HOLDER 3

CREDIT CARD

BANKACCOUNT

BANKACCOUNT

BANKACCOUNT

ADDRESS

PHONE NUMBER

PHONE NUMBER

SSN 2

UNSECURED LOAN

SSN 2

UNSECURED LOAN

Modeling a fraud ring as a graph

Page 24: Transforming Your Data: A Worked Example

https://neo4j.com/graphgist/9d627127-003b-411a-b3ce-f8d3970c2afa?ref=solutions

https://neo4j.com/graphgists/

Page 25: Transforming Your Data: A Worked Example

Credit Card Fraud

Page 26: Transforming Your Data: A Worked Example
Page 27: Transforming Your Data: A Worked Example
Page 28: Transforming Your Data: A Worked Example
Page 29: Transforming Your Data: A Worked Example

(relational)-[:TO]->(graph)

Page 30: Transforming Your Data: A Worked Example

FROM RDBMS TO GRAPHS

Page 31: Transforming Your Data: A Worked Example
Page 32: Transforming Your Data: A Worked Example

Northwind

Page 33: Transforming Your Data: A Worked Example

Northwind - the canonical RDBMS Example

Page 34: Transforming Your Data: A Worked Example

( )-[:TO]->(Graph)

Page 35: Transforming Your Data: A Worked Example
Page 36: Transforming Your Data: A Worked Example

( )-[:IS_BETTER_AS]->(Graph)

Page 37: Transforming Your Data: A Worked Example

Starting with the ER Diagram

Page 38: Transforming Your Data: A Worked Example

Locate the Foreign Keys

Page 39: Transforming Your Data: A Worked Example

Drop the Foreign Keys

Page 40: Transforming Your Data: A Worked Example

Find the JOIN Tables

Page 41: Transforming Your Data: A Worked Example

(Simple) JOIN Tables Become Relationships

Page 42: Transforming Your Data: A Worked Example

Attributed JOIN Tables -> Relationships with Properties

Page 43: Transforming Your Data: A Worked Example

As a Graph

Page 44: Transforming Your Data: A Worked Example

https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/master/readme.adoc

Page 45: Transforming Your Data: A Worked Example

Northwind

Page 46: Transforming Your Data: A Worked Example

Northwind

Page 47: Transforming Your Data: A Worked Example
Page 48: Transforming Your Data: A Worked Example
Page 49: Transforming Your Data: A Worked Example
Page 50: Transforming Your Data: A Worked Example
Page 51: Transforming Your Data: A Worked Example
Page 52: Transforming Your Data: A Worked Example
Page 53: Transforming Your Data: A Worked Example
Page 54: Transforming Your Data: A Worked Example

Neo4j Language Drivers

Page 55: Transforming Your Data: A Worked Example

Neo4j Drivers

https://neo4j.com/developer/language-guides/

Page 56: Transforming Your Data: A Worked Example

POWERING AN APP

Page 57: Transforming Your Data: A Worked Example

Simple App

Page 58: Transforming Your Data: A Worked Example

Simple App

Page 59: Transforming Your Data: A Worked Example

Simple Python Code

Page 60: Transforming Your Data: A Worked Example

Simple Python Code

Page 61: Transforming Your Data: A Worked Example

Simple Python Code

Page 62: Transforming Your Data: A Worked Example

Simple Python Code

Page 63: Transforming Your Data: A Worked Example

https://neo4j.com/developer/

Page 64: Transforming Your Data: A Worked Example

Use Case: Personalized Recommendations

Page 65: Transforming Your Data: A Worked Example

Recommendations drive user engagement

Page 66: Transforming Your Data: A Worked Example

“35 percent of what consumers purchase on Amazon and 75 percent of what they watch on Netflix come from product recommendations”

http://www.mckinsey.com/industries/retail/our-insights/how-retailers-can-keep-up-with-consumers

Page 67: Transforming Your Data: A Worked Example

Product Recommendations

Effective product recommendation algorithms has become the new standard in online retail — directly affecting revenue streams and the shopping experience.

Logistics/DeliveryRouting recommendations allows companies to save money on routing and delivery, and provide better and faster service.

Promotion recommendations

Building powerful personalized promotion engines is another area within retail that requires input from multiple data sources, and real-time, session based queries, which is an ideal task to solve with Neo4j.

Today Recommendation Engines are At the Core of Digitization in Retail

Page 68: Transforming Your Data: A Worked Example

Powerful recommendation engines rely on the connections between multiple

sources of data

Page 69: Transforming Your Data: A Worked Example

Powerful recommendation engines rely on the connections between multiple

sources of data

Page 70: Transforming Your Data: A Worked Example

Dreamhouse Series 15% off

Dreamhouse Series 15% off

The Store

Search

Hi, loginMy Account

People who bought Side Table also bought:

Coffee Table

$235Low Book Shelf

$150Bed Side Table

$90

Mobile Brick & Mortar

Multi-Channel

Web

The Store

People who bought Side Table also bought: Similar product in from Home Office Series:

Hi, loginMy AccountSearch

Dreamhouse Series 15% off Dreamhouse Series 15% off

All departments Living room | Kitchen | Hallway | Lightning | Bedroom | Garden | Home Office Space

Tr a c k O r d e r s |   G i f t C a r d s |  S t o r e fin d e r | C r e d i t C a r d | G r o c e r y P i c k u p |  H e l p

Wood Side Table

$110Green Side Table

$135Walnut Side Table

$120Coffee Table

$235Low Book Shelf

$150Bed Side Table

$90

Product Recommendations

Page 71: Transforming Your Data: A Worked Example

Dreamhouse Series 15% off

Dreamhouse Series 15% off

The Store

Search

Hi, loginMy Account

People who bought Side Table also bought:

Coffee Table

$235Low Book Shelf

$150Bed Side Table

$90

Mobile Brick & MortarWeb

The Store

People who bought Side Table also bought: Similar product in from Home Office Series:

Hi, loginMy AccountSearch

Dreamhouse Series 15% off Dreamhouse Series 15% off

All departments Living room | Kitchen | Hallway | Lightning | Bedroom | Garden | Home Office Space

Tr a c k O r d e r s |   G i f t C a r d s |  S t o r e fin d e r | C r e d i t C a r d | G r o c e r y P i c k u p |  H e l p

Wood Side Table

$110Green Side Table

$135Walnut Side Table

$120Coffee Table

$235Low Book Shelf

$150Bed Side Table

$90

Page 72: Transforming Your Data: A Worked Example

The Store

People who bought Side Table also bought: Similar product in from Home Office Series:

Hi, loginMy AccountSearch

Dreamhouse Series 15% off Dreamhouse Series 15% off

All departments Living room | Kitchen | Hallway | Lightning | Bedroom | Garden | Home Office Space

Tr a c k O r d e r s |   G i f t C a r d s |  S t o r e fin d e r | C r e d i t C a r d | G r o c e r y P i c k u p |  H e l p

Wood Side Table

$110Green Side Table

$135Walnut Side Table

$120Coffee Table

$235Low Book Shelf

$150Bed Side Table

$90

Personalized Promotions Personalized Real-Time Recommendations

Personalized Real-Time Recommendations

Page 73: Transforming Your Data: A Worked Example

The Store

People who bought Side Table also bought: Similar product in from Home Office Series:

Hi, loginMy AccountSearch

Dreamhouse Series 15% off Dreamhouse Series 15% off

All departments Living room | Kitchen | Hallway | Lightning | Bedroom | Garden | Home Office Space

Tr a c k O r d e r s |   G i f t C a r d s |  S t o r e fin d e r | C r e d i t C a r d | G r o c e r y P i c k u p |  H e l p

Wood Side Table

$110Green Side Table

$135Walnut Side Table

$120Coffee Table

$235Low Book Shelf

$150Bed Side Table

$90

Data-Model (Expressed as

a graph)

Category

Category

Product

Product

Product

Collaborative FilteringAn algorithm that considers users interactions with products, with the

assumption that other users will behave in similar ways.

Algorithm Types

Content BasedAn algorithm that considers

similarities between products and categories of products.

Customer

Customer

Product

Product

Product

Page 74: Transforming Your Data: A Worked Example

Category Price ConfigurationsLocation

Silos & Polyglot Persistence

Purchase ViewReviewReturn In-store PurchasesInventory

Products Customers / Users

Location

Purchases

RELATIONAL DB WIDE COLUMN STORE

Views

DOCUMENT STORE

User Review

RELATIONAL DB

In-Store Purchase

Shopping Cart

KEY VALUE STORE

Product Catalogue

DOCUMENT STORE

Page 75: Transforming Your Data: A Worked Example

Purchases

RELATIONAL DB WIDE COLUMN STORE

Views

DOCUMENT STORE

User Review

RELATIONAL DB

In-Store Purchase

Shopping Cart

KEY VALUE STORE

Product Catalogue

DOCUMENT STORE

Silos & Polyglot Persistence

Category Price ConfigurationsLocation Purchase ViewReviewReturn In-store PurchasesInventory

Products Customers / Users

Location

Page 76: Transforming Your Data: A Worked Example

Purchases

RELATIONAL DB WIDE COLUMN STORE

Views

DOCUMENT STORE

User Review

RELATIONAL DB

In-Store Purchase

Shopping Cart

KEY VALUE STORE

Product Catalogue

DOCUMENT STORE

Category Price ConfigurationsLocation

Polyglot Persistence

Purchase ViewReviewReturn In-store PurchasesInventory LocationCategory Price ConfigurationsLocation Purchase ViewReviewReturn In-store PurchasesInventory

Products Customers / Users

Location

Page 77: Transforming Your Data: A Worked Example

Data Lake

Purchases

RELATIONAL DB

Product Catalogue

DOCUMENT STORE WIDE COLUMN STORE

Views

DOCUMENT STORE

User Review

RELATIONAL DB

In-Store Purchase

Shopping Cart

KEY VALUE STORE

Recommendations require an operational workload — it’s in the moment, real-time!

Good for Analytics, BI, Map ReduceNon-Operational, Slow Queries

Page 78: Transforming Your Data: A Worked Example

Purchases

RELATIONAL DB

Product Catalogue

DOCUMENT STORE WIDE COLUMN STORE

Views

DOCUMENT STORE

User Review

RELATIONAL DB

In-Store Purchase

Shopping Cart

KEY VALUE STORE

Connector

Drivers: Java |  JavaScript |  Python |  .Net |  PHP |  Go |  Ruby

Apps and Systems

Real-Time Queries

Page 79: Transforming Your Data: A Worked Example

Using Data Relationships for Recommendations

Content-based filtering Recommend items based on what users have liked in the past

Collaborative filtering Predict what users like based on the similarity of their behaviors, activities and preferences to others

Movie

Person

Person

RATED

SIMILARITY

rating: 7

value: .92

Page 80: Transforming Your Data: A Worked Example

Collaborative Filtering

Page 81: Transforming Your Data: A Worked Example

Collaborative Filtering

Page 82: Transforming Your Data: A Worked Example

Collaborative Filtering

Page 83: Transforming Your Data: A Worked Example

Collaborative Filtering

Link prediction

Page 84: Transforming Your Data: A Worked Example

In Cypher

Page 85: Transforming Your Data: A Worked Example

In Cypher

Basic initial approach. Improvements:- aggregate across all purchases- scoring / normalize- compute similarity metrics

Page 86: Transforming Your Data: A Worked Example

Content Filtering

Page 87: Transforming Your Data: A Worked Example

Content Filtering

Page 88: Transforming Your Data: A Worked Example

Content Filtering w/ Cypher

Page 89: Transforming Your Data: A Worked Example

Content Filtering - Concept Hierarchy

Page 90: Transforming Your Data: A Worked Example

Content Filtering - Concept Hierarchy

Page 91: Transforming Your Data: A Worked Example

Content Filtering - Concept Hierarchy

Page 92: Transforming Your Data: A Worked Example

Content Filtering - Concept Hierarchy w/ Cypher

Page 93: Transforming Your Data: A Worked Example

Content Filtering - Concept Hierarchy w/ Cypher

Basic initial approach. Improvements:- aggregate across all purchases- cold start- variable length concept hierarchy- tag similarity / clusters

Page 94: Transforming Your Data: A Worked Example

Neo4j Sandbox

neo4jsandbox.com

Page 95: Transforming Your Data: A Worked Example

Want to learn more?

graphdatabases.com neo4j.com/sandbox

Page 96: Transforming Your Data: A Worked Example

(you)-[:HAVE]->(?)(?)<-[:ANSWERS]-(will)

Page 97: Transforming Your Data: A Worked Example

09:00-09:30 09:30-10:15

10:15-11:00 11:00-11:30 11:30-12:30

12:30-13:30 13:30-17:00

Breakfast and RegistrationThe Connected Data Imperative: Why Graphs

Transform Your Data: A Worked ExampleBreakEnterprise Ready: A Look at Neo4j in Production LunchHands-On Training Session

Agenda

APRIL 26, 2017SANTA CLARA