mirror of
https://github.com/gsi-upm/sitc
synced 2024-11-17 20:12:28 +00:00
473 lines
53 KiB
Plaintext
473 lines
53 KiB
Plaintext
|
{
|
||
|
"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": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>Source</th>\n",
|
||
|
" <th>Target</th>\n",
|
||
|
" <th>Type</th>\n",
|
||
|
" <th>weight</th>\n",
|
||
|
" <th>book</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>Addam-Marbrand</td>\n",
|
||
|
" <td>Jaime-Lannister</td>\n",
|
||
|
" <td>Undirected</td>\n",
|
||
|
" <td>3</td>\n",
|
||
|
" <td>1</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>Addam-Marbrand</td>\n",
|
||
|
" <td>Tywin-Lannister</td>\n",
|
||
|
" <td>Undirected</td>\n",
|
||
|
" <td>6</td>\n",
|
||
|
" <td>1</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>Aegon-I-Targaryen</td>\n",
|
||
|
" <td>Daenerys-Targaryen</td>\n",
|
||
|
" <td>Undirected</td>\n",
|
||
|
" <td>5</td>\n",
|
||
|
" <td>1</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>Aegon-I-Targaryen</td>\n",
|
||
|
" <td>Eddard-Stark</td>\n",
|
||
|
" <td>Undirected</td>\n",
|
||
|
" <td>4</td>\n",
|
||
|
" <td>1</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>Aemon-Targaryen-(Maester-Aemon)</td>\n",
|
||
|
" <td>Alliser-Thorne</td>\n",
|
||
|
" <td>Undirected</td>\n",
|
||
|
" <td>4</td>\n",
|
||
|
" <td>1</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" Source Target Type weight \\\n",
|
||
|
"0 Addam-Marbrand Jaime-Lannister Undirected 3 \n",
|
||
|
"1 Addam-Marbrand Tywin-Lannister Undirected 6 \n",
|
||
|
"2 Aegon-I-Targaryen Daenerys-Targaryen Undirected 5 \n",
|
||
|
"3 Aegon-I-Targaryen Eddard-Stark Undirected 4 \n",
|
||
|
"4 Aemon-Targaryen-(Maester-Aemon) Alliser-Thorne Undirected 4 \n",
|
||
|
"\n",
|
||
|
" book \n",
|
||
|
"0 1 \n",
|
||
|
"1 1 \n",
|
||
|
"2 1 \n",
|
||
|
"3 1 \n",
|
||
|
"4 1 "
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"book1.head(5)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {
|
||
|
"slideshow": {
|
||
|
"slide_type": "slide"
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6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aYMje79QVVXFwYMH4e7uwSxwslnVHzMej4eKigqUlpbit99+AwCkpaWBw+EgU64BNk8AoG7qGA0tUN413hjRBf6r4W9oBdvExAQzZ87EhQsXkJGRgY8//hhnzpyBnZ0d+vTpg7Vr1yI9Pb3OY2xtbbFhwwY8fvwYOjo66NKlC8aPH48HDx601iG9l7DZbJh37g8Wl199A4cLtqkLKisrweFwIBKJ8MMPP+DHH3/EtxsOQtM3ENZmRkxqmYD7X+oYFV3Ku8YbJbrNRVtbmwk15OTk4JtvvsGDBw/QuXNneHp6YunSpYiJiWE8LSMjIyxbtgwpKSlwd3eHn58fhgwZghs3btB0s9dE7XCRUiaGlugpVGw7Q9M3EAI7LwDAb/vOIdd+CDQ7+yNGbghZ9AWUR57GZHsF88NLRZfyrvFWim5thEIh/P39sX37dmRnZ2P16tXIz8/HBx98gHbt2mH+/PkIDQ2FUqmEpqYm5s2bh5SUFIwcORIBAQHo3r07Tp482aL9Xyl1w0VDtHKQm5sL/WHzodnZH/rD50No3wUCa3cmpCBTsqBlYAzRrV3IvXeRmYeKLuVd443vvfCyEEIQFRWFoKAgBAUFoaioCMOHD8fIkSPRp08f8Pl8KBQKHDt2DCtWrIBEIsGCBQswbtw48Hi8tjb/nWPML4cQUarG/F8WcQrIeQT
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import networkx as nx\n",
|
||
|
"\n",
|
||
|
"G1 = nx.from_pandas_edgelist(book1, 'Source', 'Target', ['weight']) #df, source, target, [columns with attrbs]\n",
|
||
|
"\n",
|
||
|
"pos = nx.spring_layout(G1)\n",
|
||
|
"#pos = nx.circular_layout(G1)\n",
|
||
|
"#pos = nx.spectral_layout(G1)\n",
|
||
|
"#pos = nx.random_layout(G1)\n",
|
||
|
"nx.draw_networkx(G1, pos = pos, node_size=10, with_labels=False) "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"slideshow": {
|
||
|
"slide_type": "slide"
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"Let's inspect..."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {
|
||
|
"slideshow": {
|
||
|
"slide_type": "fragment"
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"('Jaime-Lannister', 'Loras-Tyrell', {'weight': 3})"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"list(G1.edges(data=True))[16]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"slideshow": {
|
||
|
"slide_type": "slide"
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"## Most important nodes"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"metadata": {
|
||
|
"slideshow": {
|
||
|
"slide_type": "fragment"
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"[('Eddard-Stark', 0.3548387096774194),\n",
|
||
|
" ('Robert-Baratheon', 0.2688172043010753),\n",
|
||
|
" ('Tyrion-Lannister', 0.24731182795698928),\n",
|
||
|
" ('Catelyn-Stark', 0.23118279569892475),\n",
|
||
|
" ('Jon-Snow', 0.19892473118279572),\n",
|
||
|
" ('Robb-Stark', 0.18817204301075272),\n",
|
||
|
" ('Sansa-Stark', 0.18817204301075272),\n",
|
||
|
" ('Bran-Stark', 0.17204301075268819),\n",
|
||
|
" ('Cersei-Lannister', 0.16129032258064518),\n",
|
||
|
" ('Joffrey-Baratheon', 0.16129032258064518)]"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 6,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"degree_1 = nx.degree_centrality(G1)\n",
|
||
|
"sorted(degree_1.items(), key=lambda x:x[1], reverse=True)[0:10]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"slideshow": {
|
||
|
"slide_type": "slide"
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"## Histogram of degree centrality"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"metadata": {
|
||
|
"slideshow": {
|
||
|
"slide_type": "fragment"
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAQAElEQVR4nO3dfYxld13H8ffHrm0tBrtlx6buVmaRFdMSTOtYq0REirI8dZvYkOIDK2yyQaqgkEBLjU1MSIoasSQIWWntkpA+WNFu5EFrKRISW5iW0kdKly2lu+nDQKEIGLDw9Y85xct0dmfuPffOw8/3K5nMOb9zzj2fPd397NnfuXeaqkKS1JYfWe0AkqTxs9wlqUGWuyQ1yHKXpAZZ7pLUoA2rHQBg06ZNNT09vdoxJGldueWWW75SVVOLbVsT5T49Pc3s7Oxqx5CkdSXJA4fb5rSMJDXIcpekBlnuktQgy12SGrRkuSe5PMmjSe5cZNtbklSSTd16krw7yf4ktyc5fRKhJUlHtpw79yuA7QsHk5wM/Cbw5YHhlwLbuq/dwHv7R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YPVtWHuuFHkpzUbT8JeLRfREnSsPq8WybAZcA9VfXXA5v2ATu75Z3AdaPHkySNos+0zPOB3wPuSHJbN/Z24BLgmiS7gAeAV/VKKEka2sjlXlWfAnKYzWeN+rqSpP78hKokNchyl6QGWe6S1CDLXZIa1PtDTFp5q/XhKfADVNJ64Z27JDXIcpekBlnuktQgy12SGmS5S1KDLHdJapDlLkkNstwlqUGWuyQ1yHKXpAZZ7pLUIH+2jNYFf56ONBzv3CWpQd65ayireQctafksd2kJq/UXmtNB6sNpGUlq0MTu3JNsBy4FjgLeX1WXTOpcUov
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.hist(list(nx.degree_centrality(G1).values()))\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"slideshow": {
|
||
|
"slide_type": "skip"
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"## References\n",
|
||
|
"* [NetworkX introduction](https://mriduls.github.io/pydata-networkx/introduction-and-game-of-thrones-instructor.html)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"slideshow": {
|
||
|
"slide_type": "skip"
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"## Licence"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"slideshow": {
|
||
|
"slide_type": "skip"
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
|
||
|
"\n",
|
||
|
"© Carlos A. Iglesias, Universidad Politécnica de Madrid."
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"celltoolbar": "Slideshow",
|
||
|
"datacleaner": {
|
||
|
"position": {
|
||
|
"top": "50px"
|
||
|
},
|
||
|
"python": {
|
||
|
"varRefreshCmd": "try:\n print(_datacleaner.dataframe_metadata())\nexcept:\n print([])"
|
||
|
},
|
||
|
"window_display": false
|
||
|
},
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3 (ipykernel)",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.8.12"
|
||
|
},
|
||
|
"latex_envs": {
|
||
|
"LaTeX_envs_menu_present": true,
|
||
|
"autocomplete": true,
|
||
|
"bibliofile": "biblio.bib",
|
||
|
"cite_by": "apalike",
|
||
|
"current_citInitial": 1,
|
||
|
"eqLabelWithNumbers": true,
|
||
|
"eqNumInitial": 1,
|
||
|
"hotkeys": {
|
||
|
"equation": "Ctrl-E",
|
||
|
"itemize": "Ctrl-I"
|
||
|
},
|
||
|
"labels_anchors": false,
|
||
|
"latex_user_defs": false,
|
||
|
"report_style_numbering": false,
|
||
|
"user_envs_cfg": false
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 1
|
||
|
}
|