1
0
mirror of https://github.com/gsi-upm/sitc synced 2024-12-22 03:38:13 +00:00

Uploaded SNA files

This commit is contained in:
Carlos A. Iglesias 2024-04-17 17:23:28 +02:00 committed by GitHub
parent dd6c053109
commit 2c53b81299
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 6409 additions and 0 deletions

View File

@ -0,0 +1,154 @@
{
"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": "slide"
}
},
"source": [
"# Introduction to Network Analysis\n",
" \n",
"In this session, we are going to get more insight regarding how to analyze and visualize social networks.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Objectives\n",
"\n",
"The main objectives of this session are:\n",
"* Understanding why networks are important in data science\n",
"* Experimenting with network analysis with networkx."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Table of Contents"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"1. [Home](0_Intro_Network_Analysis.ipynb)\n",
"2. [First Steps](1_First_Steps.ipynb)\n",
"3. [Working_with_Graphs](2_Working_with_Graphs.ipynb)\n",
"4. [Network Analysis](3_Network_Analysis.ipynb)\n",
"5. [Social Networks](4_Social_Networks.ipynb)\n",
"6. [Pandas integration](5_Pandas.ipynb)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"## Licence\n",
"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.11.7"
},
"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": 4
}

1301
sna/1_First_Steps.ipynb Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,374 @@
{
"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": {},
"source": [
"# Exercise: Florentine families"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import networkx as nx\n",
"import warnings\n",
"warnings.simplefilter(action='ignore', category=FutureWarning)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"G_florentine = nx.florentine_families_graph()"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Exercise: Star Wars"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import networkx as nx\n",
"\n",
"# Taken from https://gist.github.com/codingthat/be03565bd97e789a3835b50235ad562f\n",
"# The original dataset is from:\n",
"# Gabasova, E. (2016). Star Wars social network. DOI: https://doi.org/10.5281/zenodo.1411479\n",
"# \n",
"# Simplified by Federico Albanese.\n",
"\n",
"characters = [\"R2-D2\",\n",
" \"CHEWBACCA\",\n",
" \"C-3PO\",\n",
" \"LUKE\",\n",
" \"DARTH VADER\",\n",
" \"CAMIE\",\n",
" \"BIGGS\",\n",
" \"LEIA\",\n",
" \"BERU\",\n",
" \"OWEN\",\n",
" \"OBI-WAN\",\n",
" \"MOTTI\",\n",
" \"TARKIN\",\n",
" \"HAN\",\n",
" \"DODONNA\",\n",
" \"GOLD LEADER\",\n",
" \"WEDGE\",\n",
" \"RED LEADER\",\n",
" \"RED TEN\"]\n",
"\n",
"\n",
"edges = [(\"CHEWBACCA\", \"R2-D2\"),\n",
" (\"C-3PO\",\"R2-D2\"),\n",
" (\"BERU\", \"R2-D2\"),\n",
" (\"LUKE\", \"R2-D2\"),\n",
" (\"OWEN\", \"R2-D2\"),\n",
" (\"OBI-WAN\", \"R2-D2\"),\n",
" (\"LEIA\", \"R2-D2\"),\n",
" (\"BIGGS\", \"R2-D2\"),\n",
" (\"HAN\", \"R2-D2\"),\n",
" (\"CHEWBACCA\", \"OBI-WAN\"),\n",
" (\"C-3PO\", \"CHEWBACCA\"),\n",
" (\"CHEWBACCA\", \"LUKE\"),\n",
" (\"CHEWBACCA\", \"HAN\"),\n",
" (\"CHEWBACCA\", \"LEIA\"),\n",
" (\"CAMIE\", \"LUKE\"),\n",
" (\"BIGGS\", \"CAMIE\"),\n",
" (\"BIGGS\", \"LUKE\"),\n",
" (\"DARTH VADER\", \"LEIA\"),\n",
" (\"BERU\", \"LUKE\"),\n",
" (\"BERU\", \"OWEN\"),\n",
" (\"BERU\", \"C-3PO\"),\n",
" (\"LUKE\", \"OWEN\"),\n",
" (\"C-3PO\", \"LUKE\"),\n",
" (\"C-3PO\", \"OWEN\"),\n",
" (\"C-3PO\", \"LEIA\"),\n",
" (\"LEIA\", \"LUKE\"),\n",
" (\"BERU\", \"LEIA\"),\n",
" (\"LUKE\", \"OBI-WAN\"),\n",
" (\"C-3PO\", \"OBI-WAN\"),\n",
" (\"LEIA\", \"OBI-WAN\"),\n",
" (\"MOTTI\", \"TARKIN\"),\n",
" (\"DARTH VADER\", \"MOTTI\"),\n",
" (\"DARTH VADER\", \"TARKIN\"),\n",
" (\"HAN\", \"OBI-WAN\"),\n",
" (\"HAN\", \"LUKE\"),\n",
" (\"C-3PO\", \"HAN\"),\n",
" (\"LEIA\", \"MOTT\"),\n",
" (\"LEIA\", \"TARKIN\"),\n",
" (\"HAN\", \"LEIA\"),\n",
" (\"DARTH VADER\", \"OBI-WAN\"),\n",
" (\"DODONNA\", \"GOLD LEADER\"),\n",
" (\"DODONNA\", \"WEDGE\"),\n",
" (\"DODONNA\", \"LUKE\"),\n",
" (\"GOLD LEADER\", \"WEDGE\"),\n",
" (\"GOLD LEADER\", \"LUKE\"),\n",
" (\"LUKE\", \"WEDGE\"),\n",
" (\"BIGGS\", \"LEIA\"),\n",
" (\"LEIA\", \"RED LEADER\"),\n",
" (\"LUKE\", \"RED LEADER\"),\n",
" (\"BIGGS\", \"RED LEADER\"),\n",
" (\"BIGGS\", \"C-3PO\"),\n",
" (\"C-3PO\", \"RED LEADER\"),\n",
" (\"RED LEADER\", \"WEDGE\"),\n",
" (\"GOLD LEADER\", \"RED LEADER\"),\n",
" (\"BIGGS\", \"WEDGE\"),\n",
" (\"RED LEADER\", \"RED TEN\"),\n",
" (\"BIGGS\", \"GOLD LEADER\"),\n",
" (\"LUKE\", \"RED TEN\")]\n",
"\n",
"G_starWars = nx.Graph()\n",
"\n",
"\n",
"G_starWars.add_nodes_from(characters)\n",
"G_starWars.add_edges_from(edges)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise\n",
"In this exercise we are going to practice some of the concepts of the session.\n",
"\n",
"Answer the following questions using the object *G_starWars* and *G_florentine*."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Number of nodes"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Number of edges"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Get the list of nodes"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Get the list of edges"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Draw the graph\n",
"\n",
"Hint. Use different layouts (circular, spring, ...)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Think of interesting micro, meso and macro metrics"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Analyze ego networks of interesting nodes."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Analyze communities"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"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",
"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.11.7"
},
"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": 4
}

2230
sna/3_Network_Analysis.ipynb Normal file

File diff suppressed because one or more lines are too long

865
sna/4_Social_Networks.ipynb Normal file

File diff suppressed because one or more lines are too long

472
sna/5_Pandas.ipynb Normal file

File diff suppressed because one or more lines are too long