Built with datascienceportfol.io

Game of Thrones Network Analysis

Project photo

Project links

Skills

About this project

Game of Thrones Network Analysis — Full Project Overview

Project Description
This project applies Social Network Analysis (SNA) to the Game of Thrones book series using Python. The aim is to explore and visualize the relationships between characters across all five books by constructing networks where each character is a node and interactions are represented by edges. Using network analysis tools such as centrality metrics, community detection, and graph visualizations, the study reveals how major characters influence the storyline and how their roles evolve over time.

Objective

  • Build character interaction networks for each book in the series.

  • Use graph theory to determine which characters are most central or influential.

  • Detect hidden communities and alliances that reflect narrative or political groupings.

  • Observe how character importance changes as the story progresses.

  • Visualize network patterns and relationships in an intuitive, data-driven way.

Tools & Technologies

  • Programming Language: Python

  • Libraries: NetworkX, Pandas, Matplotlib, Seaborn

  • Environment: Jupyter Notebook

  • Dataset: Kaggle (Books 1 to 5 character interactions)

Dataset Overview
Each dataset includes rows representing character interactions within a specific book. Each row has:

  • Source: Initiating character

  • Target: Receiving character

  • Weight: Frequency of interaction

  • Type: All connections are undirected

  • Book: Book number (1–5)

Example sizes:

  • Book 1: 684 interactions, 187 characters

  • Book 2: 775 interactions, 259 characters

  • Book 3: 1008 interactions, 303 characters

  • Book 4: 682 interactions, 274 characters

  • Book 5: 761 interactions, 285 characters

Methodology

  1. Network Construction
    Each book’s data was used to build an undirected, weighted graph. These graphs represent how often characters interact, allowing structural patterns to emerge.

  2. Centrality Analysis
    Several centrality measures were used to evaluate character importance:

  • Degree Centrality: Characters with the most direct connections.

  • Betweenness Centrality: Characters that act as bridges between different groups or story arcs.

  • Closeness Centrality: Characters who can quickly reach others, indicating influence and reach.

  • PageRank: An adaptation of Google's algorithm to measure influence through indirect connections.

  1. Community Detection
    Modularity-based greedy algorithms were applied to find groups of characters who interact more frequently with each other than with the rest of the network. These communities often correspond to narrative groupings, like family houses or political alliances.

  2. Correlation Matrix
    The relationship between different centrality measures was examined using a correlation heatmap. This helped determine whether different metrics consistently identified the same characters as important.

  3. Character Evolution Over Time
    The evolution of centrality scores across the five books was visualized to identify shifts in influence. Characters like Eddard Stark dominated early in the series, while Jon Snow, Tyrion Lannister, and Daenerys Targaryen rose in importance in later books.

  4. Structural Network Analysis
    Advanced network metrics such as cliques and k-core decomposition were used to analyze closely connected subgroups. Degree distributions were plotted, revealing that the networks exhibit scale-free properties—few characters have many connections, and many characters have few, just like in real social networks.

Key Insights

  • Eddard Stark is the most central character in Book 1, but is later replaced by Tyrion, Jon Snow, and Daenerys as the narrative progresses.

  • Betweenness centrality shows that characters like Tyrion and Jon often bridge multiple communities, acting as crucial connectors in the storyline.

  • Detected communities align well with major houses and plotlines, reflecting the series' narrative structure.

  • High correlation among centrality metrics confirms their reliability for identifying key figures.

  • The presence of a scale-free structure suggests realistic complexity in the social network of the story.

Skills Demonstrated
Technical Skills: Python, NetworkX, Pandas, Matplotlib, Seaborn, Graph Theory, Data Visualization, Jupyter Notebook
Analytical Skills: Centrality Metrics, Community Detection, Temporal Analysis, Correlation Analysis, Network Modeling
Soft Skills: Problem Solving, Research, Critical Thinking, Storytelling with Data, Documentation

Future Enhancements

  • Add sentiment analysis to differentiate between positive and negative character relationships.

  • Use dynamic network modeling on a chapter-by-chapter basis.

  • Incorporate character-level data from fan wikis for richer feature sets.

  • Apply deep learning models (e.g., RNNs or GNNs) to predict character influence dynamically.

  • Automate visual storytelling through animated network evolution.