{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "![](images/EscUpmPolit_p.gif \"UPM\")" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "# Course Notes for Learning Intelligent Systems" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © Carlos A. Iglesias" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "## [Introduction to Network Analysis](0_Intro_Network_Analysis.ipynb)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Pandas integration" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "## Dataset Game of Thrones" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "Character Interaction Networks for George R. R. Martin's \"A Song of Ice and Fire\" saga\n", "\n", "Available at https://github.com/mathbeveridge/asoiaf\n", "\n", "Based on https://mriduls.github.io/pydata-networkx/introduction-and-game-of-thrones-instructor.html" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "import pandas as pd\n", "import networkx as nx\n", "import matplotlib.pyplot as plt\n", "from matplotlib import cm\n", "import networkx.algorithms.connectivity as nxcon\n", "import numpy as np\n", "import warnings\n", "warnings.filterwarnings('ignore')\n", "\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "slideshow": { "slide_type": "slide" } }, "outputs": [], "source": [ "book1 = pd.read_csv('https://raw.githubusercontent.com/mathbeveridge/asoiaf/master/data/asoiaf-book1-edges.csv')" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "We inspect the dataset. **weight** shows the number of interactions of the characters in the book." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "slideshow": { "slide_type": "fragment" } }, "outputs": [ { "data": { "text/html": [ "
\n", " | Source | \n", "Target | \n", "Type | \n", "weight | \n", "book | \n", "
---|---|---|---|---|---|
0 | \n", "Addam-Marbrand | \n", "Jaime-Lannister | \n", "Undirected | \n", "3 | \n", "1 | \n", "
1 | \n", "Addam-Marbrand | \n", "Tywin-Lannister | \n", "Undirected | \n", "6 | \n", "1 | \n", "
2 | \n", "Aegon-I-Targaryen | \n", "Daenerys-Targaryen | \n", "Undirected | \n", "5 | \n", "1 | \n", "
3 | \n", "Aegon-I-Targaryen | \n", "Eddard-Stark | \n", "Undirected | \n", "4 | \n", "1 | \n", "
4 | \n", "Aemon-Targaryen-(Maester-Aemon) | \n", "Alliser-Thorne | \n", "Undirected | \n", "4 | \n", "1 | \n", "