{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# INST728E - Module 10. Graph and Network Modeling\n", "\n", "Information flows and social networks are important considerations during crises, when people are trying to get updates on safe spaces, loved ones, places of shelter, etc.\n", "Twitter is noisy though, and a lot of the data may be irrelevant, condolences/thoughts expressed by celebrities, or otherwise uninformative.\n", "Using network analysis, we can get some idea about who the most important Twitter users were during this time, and how people split into groups online.\n", "\n", "For this analysis, we'll use the NetworkX package to construct a social graph of how people interact. Each person in our Twitter data will be a node in our graph, and edges in the graph will represent mentions during this timeframe.\n", "Then we will explore a few simple analytical methods in network analysis, including:\n", "\n", "- Central accounts\n", "- Visualization" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline\n", "\n", "import datetime\n", "import json\n", "import string\n", "import os\n", "\n", "import numpy as np\n", "\n", "# For plotting\n", "import matplotlib.pyplot as plt\n", "\n", "# Network analysis\n", "import networkx as nx\n", "\n", "import nltk # Used for FreqDist" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Event Description" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "crisisInfo = {\n", " \n", " \"brussels\": {\n", " \"name\": \"Brussels Transit Attacks\",\n", " \"time\": 1458629880, # Timestamp in seconds since 1/1/1970, UTC\n", " # 22 March 2016, 6:58 UTC to 08:11 UTC\n", " \"directory\": \"brussels\",\n", " \"keywords\": [\"brussels\", \"bomb\", \"belgium\", \"explosion\"],\n", " \"box\": {\n", " \"lowerLeftLon\": 2.54563,\n", " \"lowerLeftLat\": 49.496899,\n", " \"upperRightLon\": 6.40791,\n", " \"upperRightLat\": 51.5050810,\n", " }\n", " },\n", "}" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Replace the name below with your selected crisis\n", "selectedCrisis = \"brussels\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "