Book Image

Network Science with Python

By : David Knickerbocker
Book Image

Network Science with Python

By: David Knickerbocker

Overview of this book

Network analysis is often taught with tiny or toy data sets, leaving you with a limited scope of learning and practical usage. Network Science with Python helps you extract relevant data, draw conclusions and build networks using industry-standard – practical data sets. You’ll begin by learning the basics of natural language processing, network science, and social network analysis, then move on to programmatically building and analyzing networks. You’ll get a hands-on understanding of the data source, data extraction, interaction with it, and drawing insights from it. This is a hands-on book with theory grounding, specific technical, and mathematical details for future reference. As you progress, you’ll learn to construct and clean networks, conduct network analysis, egocentric network analysis, community detection, and use network data with machine learning. You’ll also explore network analysis concepts, from basics to an advanced level. By the end of the book, you’ll be able to identify network data and use it to extract unconventional insights to comprehend the complex world around you.
Table of Contents (17 chapters)
1
Part 1: Getting Started with Natural Language Processing and Networks
5
Part 2: Graph Construction and Cleanup
9
Part 3: Network Science and Social Network Analysis

What this book covers

Chapter 1, Introducing Natural Language Processing, introduces natural language processing (NLP) and how language and networks relate. We will discuss what NLP is, where it can be useful, and walk through several use cases. By the end of this chapter, the reader will have a basic understanding of NLP, what it is, what it looks like, and how to get started in using NLP to investigate data.

Chapter 2, Network Analysis, introduces network analysis, which is useful for analyzing aspects of a network, such as its overall structure, key nodes, communities, and components. We will discuss different types of networks and different use cases, and we will walk through a simple workflow for collecting data for network research. This chapter gives a gentle introduction to understanding networks and how understanding networks may be useful in solving problems.

Chapter 3, Useful Python Libraries, discusses the Python libraries used in this book, including where to go for installation instructions and more. This chapter also provides some starter code to start using libraries and to check that they are working. Libraries are grouped into categories so that they can be easily understood and compared. We will discuss Python libraries for data analysis and processing, data visualization, NLP, network analysis and visualization, and machine learning (ML). This book does not depend on a graph database, reducing the overhead of learning network analysis skills.

Chapter 4, NLP and Network Synergy, discusses how to take text data and convert it into networks that can be analyzed. We will learn to load text data, extract entities (people, places, organizations, and more), and construct social networks using text alone. This allows us to create visual maps of how characters and people interact in a body of text, and these can serve as a way to interactively gain a richer contextual awareness of the content or entities being studied.

In this chapter, we will also discuss crawling, also known as web scraping. Learning how to collect data from the internet and use it in NLP and network analysis will supercharge an individual’s ability to learn about either or both. It also unlocks the ability to research things that interest you rather than using someone else’s datasets.

Finally, we will convert the text into an actual network and visualize it. This is a very long chapter because it covers each of the steps involved in converting text into networks.

Chapter 5, Even Easier Scraping, shows even easier methods for collecting text data from the internet. Certain Python libraries have been created for pulling text data from news sites, blog websites, and social media. This chapter will show you how to easily and quickly get clean text data for use in downstream processes. In this chapter, we will convert text into an actual network, and then we will visualize the network.

Chapter 6, Graph Construction and Cleaning, dives into working with networks. The chapter starts by showing how to create a graph using an edge list and then describes important concepts such as nodes and edges. Over the course of the chapter, we will learn to add, edit, and remove nodes and edges from graphs, which is all a part of graph construction and cleaning. We will conclude the chapter with a simulation of a network attack, showing the catastrophically destructive effect that removing even a few key nodes can have on a network. This shows the importance that individual nodes have on an entire network.

Chapter 7, Whole Network Analysis, is where we really get started with network analysis. For instance, we will look for answers on the size, complexity, and structure of the network. We will look for influential and important nodes and use connected components to identify structures that exist in the network. We will also briefly discuss community detection, which is covered in much greater depth in Chapter 9.

Chapter 8, Egocentric Network Analysis, investigates the egocentric networks that exist in a network. This means that we will look closer at nodes of interest (ego nodes) and the nodes that surround them (alters). The goal is to understand the social fabric that exists around an ego node. This can also be useful for recognizing the communities that an individual belongs to.

Chapter 9, Community Detection, discusses several approaches to identifying the communities that exist in a network. Several powerful algorithms for community detection will be shown and discussed. We will also discuss how connected components can be used to identify communities.

Chapter 10, Supervised Machine Learning on Network Data, shows how we can use networks to create training data for ML classification tasks. In this chapter, we will create training data by hand, extracting useful features from a network. We will then combine those features into training data and build a model for classification.

Chapter 11, Unsupervised Machine Learning on Network Data, shows how unsupervised ML can be useful for creating node embeddings that can be used for classification. In the previous chapter, we created network features by hand. In this chapter, we will show how to create node embeddings using Karate Club and then use them for classification. We will also show how to use Karate Club’s GraphML models for community detection.