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.