Graph Data Modeling in Python: A practical guide to curating, analyzing, and modeling data with graphs

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Learn how to transform, store, evolve, refactor, model, and create graph projections using the Python programming language Key Features • Transform relational data models into graph data model while learning key applications along the way • Discover common challenges in graph modeling and analysis, and learn how to overcome them • Practice real-world use cases of community detection, knowledge graph, and recommendation network Book Description Graphs have become increasingly integral to powering the products and services we use in our daily lives, driving social media, online shopping recommendations, and even fraud detection. With this book, you'll see how a good graph data model can help enhance efficiency and unlock hidden insights through complex network analysis. Graph Data Modeling in Python will guide you through designing, implementing, and harnessing a variety of graph data models using the popular open source Python libraries NetworkX and igraph. Following practical use cases and examples, you'll find out how to design optimal graph models capable of supporting a wide range of queries and features. Moreover, you'll seamlessly transition from traditional relational databases and tabular data to the dynamic world of graph data structures that allow powerful, path-based analyses. As well as learning how to manage a persistent graph database using Neo4j, you'll also get to grips with adapting your network model to evolving data requirements. By the end of this book, you'll be able to transform tabular data into powerful graph data models. In essence, you'll build your knowledge from beginner to advanced-level practitioner in no time. What you will learn • Design graph data models and master schema design best practices • Work with the NetworkX and igraph frameworks in Python • Store, query, ingest, and refactor graph data • Store your graphs in memory with Neo4j • Build and work with projections and put them into practice • Refactor schemas and learn tactics for managing an evolved graph data model Who this book is for If you are a data analyst or database developer interested in learning graph databases and how to curate and extract data from them, this is the book for you. It is also beneficial for data scientists and Python developers looking to get started with graph data modeling. Although knowledge of Python is assumed, no prior experience in graph data modeling theory and techniques is required.

Author(s): Gary Hutson, Matt Jackson
Edition: 1
Publisher: Packt Publishing
Year: 2023

Language: English
Commentary: Publisher's PDF
Pages: 236
City: Birmingham, UK
Tags: Debugging; Python; Relational Databases; Pipelines; Graph Data Model; Cypher; Neo4j; Refactoring; NetworkX; Knowledge Graphs

Cover
Title Page
Copyright
Dedication
Contributors
Table of Contents
Preface
Part 1: Getting Started with Graph Data Modeling
Chapter 1: Introducing Graphs in the Real World
Technical requirements
Why should you use graphs?
Composite components of a graph
The fundamentals of nodes and edges and the properties of a graph
Undirected graphs
Directed graphs
Node properties
Heterogeneous graphs
Schema design
Comparing RDBs and GDBs
GDBs to the rescue
The use of graphs across various industries
Introduction to NetworkX and igraph
NetworkX basics
igraph basics
Summary
Chapter 2: Working with GraphData Models
Technical requirements
Making the transition from tabular to graph data
Examining the data
Designing a schema
Implementing the model in Python
Adding nodes and attributes
Adding edges
Writing a generic graph import method
The most popular TV show – a real-world use case
Examining the graph structure
Measuring connectedness
Looking at the top degree nodes
Using select() to interrogate the graph
Properties of our popular nodes
Summary
Part 2: Making the Graph Transition
Chapter 3: Data Model Transformation – Relational to Graph Databases
Technical requirements
Recommending a game to a user
Installing MySQL
Setting up a MySQL database
Querying MySQL in Python
Examining the data in Python
Path-based analytics in tabular data
From relational to graph databases
Schema design
Ingestion considerations
Path-based analytics in igraph
Our recommendation system
Generic MySQL to igraph methods
A more advanced recommendation system using Jaccard similarity
Summary
Chapter 4: Building a Knowledge Graph
Technical requirements
Introducing knowledge graphs
Cleaning the data for our knowledge graph
Ingesting data into a knowledge graph
Designing a knowledge graph schema
Linking text to terms
Constructing the knowledge graph
Knowledge graph analysis and community detection
Examining the knowledge graph structure
Identifying abstracts of interest
Identifying fields with community detection
Summary
Part 3: Storaging and Productionizing Graphs
Chapter 5: Working with Graph Databases
Technical requirements
Using graph databases
Neo4j as a graph database
The Cypher query language
Querying Neo4j from Python
Storing a graph in Neo4j
Preprocessing data
Moving nodes, edges, and properties to Neo4j
Optimizing travel with Python and Cypher
Travel recommendations
Moving to ingestion pipelines
Summary
Chapter 6: Pipeline Development
Technical requirements
Graph pipeline development
A graph database for retail
Designing a schema and pipeline
Setting up a new database
Schema design
Adding static product information
Simulating customer interactions
Making product recommendations
Product recommendations by brand
Drawing on other customers’ purchases
Using similarity scores to recommend products
Summary
Chapter 7: Refactoring and Evolving Schemas
Technical requirements
Refactoring reasoning
Change in relational and graph databases
Effectively evolving with graph schema design
Putting the changes into development
Initializing a new database
Adding constraints
Pre-change schema
Updating the schema
Summary
Part 4: Graphing Like a Pro
Chapter 8: Perfect Projections
Technical requirements
What are projections?
How to use a projection
Creating a projection in igraph
Creating a projection in Neo4j
Putting the projection to work
Analyzing the igraph actor projection
Exploring connected components
Exploring cliques in our graph
Analyzing the Neo4j film projection
Summary
Chapter 9: Common Errors and Debugging
Technical requirements
Debugging graph issues
Common igraph issues
No nodes in the graph
Node IDs in igraph
Adding properties
Using the select method
Chained statements and select
Efficiency and path lengths
Common Neo4j issues
Slow writing from file to Neo4j
Indexing for query performance
Caching results
Memory limitations
Handling duplicates with MERGE
Handling duplicates with constraints
EXPLAIN, PROFILE, and the eager operator
Summary
Index
Other Books You May Enjoy