|
65 | 65 | "metadata": {},
|
66 | 66 | "outputs": [],
|
67 | 67 | "source": [
|
68 |
| - "import urllib.request\n", |
| 68 | + "from delphi.utils import get_data_from_url\n", |
69 | 69 | "import pickle\n",
|
70 | 70 | "url = 'http://vision.cs.arizona.edu/adarsh/export/demos/data/pi_mtg_demo.pkl'\n",
|
71 |
| - "with urllib.request.urlopen(url) as f:\n", |
72 |
| - " sts = pickle.load(f) " |
| 71 | + "sts = pickle.load(get_data_from_url(url)) " |
73 | 72 | ]
|
74 | 73 | },
|
75 | 74 | {
|
|
195 | 194 | "## Mapping concepts to indicators"
|
196 | 195 | ]
|
197 | 196 | },
|
| 197 | + { |
| 198 | + "cell_type": "code", |
| 199 | + "execution_count": null, |
| 200 | + "metadata": {}, |
| 201 | + "outputs": [], |
| 202 | + "source": [ |
| 203 | + "%load_ext autoreload\n", |
| 204 | + "%autoreload 2" |
| 205 | + ] |
| 206 | + }, |
198 | 207 | {
|
199 | 208 | "cell_type": "code",
|
200 | 209 | "execution_count": null,
|
|
206 | 215 | "outputs": [],
|
207 | 216 | "source": [
|
208 | 217 | "from delphi.quantification import map_concepts_to_indicators\n",
|
209 |
| - "map_concepts_to_indicators(G, 2)\n", |
| 218 | + "url = 'http://vision.cs.arizona.edu/adarsh/export/demos/data/concept_to_indicator_mapping.txt'\n", |
| 219 | + "mapping = get_data_from_url(url)\n", |
| 220 | + "map_concepts_to_indicators(G, 2, mapping)\n", |
210 | 221 | "visualize(G, indicators=True)"
|
211 | 222 | ]
|
212 | 223 | },
|
|
233 | 244 | "cell_type": "code",
|
234 | 245 | "execution_count": null,
|
235 | 246 | "metadata": {
|
| 247 | + "scrolled": false, |
236 | 248 | "slideshow": {
|
237 | 249 | "slide_type": "subslide"
|
238 | 250 | }
|
|
242 | 254 | "from datetime import datetime\n",
|
243 | 255 | "from delphi.parameterization import parameterize\n",
|
244 | 256 | "date = datetime(2014, 1, 1)\n",
|
245 |
| - "parameterize(G, datetime(2014, 1,1))\n", |
| 257 | + "url = 'http://vision.cs.arizona.edu/adarsh/export/demos/data/south_sudan_data.csv'\n", |
| 258 | + "parameterize(G, datetime(2014, 1,1), get_data_from_url(url))\n", |
246 | 259 | "visualize(G, indicators=True, indicator_values = True,\n",
|
247 | 260 | " graph_label=f'Causal Analysis Graph for South Sudan, {date.year}')"
|
248 | 261 | ]
|
|
258 | 271 | "## Infer transition model"
|
259 | 272 | ]
|
260 | 273 | },
|
261 |
| - { |
262 |
| - "cell_type": "code", |
263 |
| - "execution_count": null, |
264 |
| - "metadata": {}, |
265 |
| - "outputs": [], |
266 |
| - "source": [ |
267 |
| - "jt.display_image('images/delphi_model.png')" |
268 |
| - ] |
269 |
| - }, |
270 | 274 | {
|
271 | 275 | "cell_type": "code",
|
272 | 276 | "execution_count": null,
|
|
277 | 281 | },
|
278 | 282 | "outputs": [],
|
279 | 283 | "source": [
|
280 |
| - "%time G.infer_transition_model(res=10000)" |
| 284 | + "url = 'http://vision.cs.arizona.edu/adarsh/export/demos/data/adjectiveData.tsv'\n", |
| 285 | + "G.infer_transition_model(get_data_from_url(url), 10000)" |
281 | 286 | ]
|
282 | 287 | },
|
283 | 288 | {
|
|
317 | 322 | "## Execute model"
|
318 | 323 | ]
|
319 | 324 | },
|
320 |
| - { |
321 |
| - "cell_type": "code", |
322 |
| - "execution_count": null, |
323 |
| - "metadata": {}, |
324 |
| - "outputs": [], |
325 |
| - "source": [ |
326 |
| - "%load_ext autoreload\n", |
327 |
| - "%autoreload 2" |
328 |
| - ] |
329 |
| - }, |
330 | 325 | {
|
331 | 326 | "cell_type": "code",
|
332 | 327 | "execution_count": null,
|
|
422 | 417 | "outputs": [],
|
423 | 418 | "source": [
|
424 | 419 | "url = 'http://vision.cs.arizona.edu/adarsh/export/demos/data/pi_mtg_demo_unfiltered.pkl'\n",
|
425 |
| - "with urllib.request.urlopen(url) as f:\n", |
426 |
| - " sts = pickle.load(f) " |
427 |
| - ] |
428 |
| - }, |
429 |
| - { |
430 |
| - "cell_type": "code", |
431 |
| - "execution_count": null, |
432 |
| - "metadata": { |
433 |
| - "slideshow": { |
434 |
| - "slide_type": "subslide" |
435 |
| - } |
436 |
| - }, |
437 |
| - "outputs": [], |
438 |
| - "source": [ |
439 |
| - "from delphi.subgraphs import *\n", |
440 |
| - "G = AnalysisGraph.from_statements(sts)\n", |
441 |
| - "merge_nodes(G, 'food_security', 'food_insecurity', same_polarity=False)\n", |
442 |
| - "G = get_subgraph_for_concept(G, 'food_insecurity', depth_limit=1)\n", |
443 |
| - "visualize(G, nodes_to_highlight='food_insecurity')" |
| 420 | + "sts=pickle.load(get_data_from_url(url))" |
444 | 421 | ]
|
445 | 422 | },
|
446 | 423 | {
|
|
453 | 430 | },
|
454 | 431 | "outputs": [],
|
455 | 432 | "source": [
|
| 433 | + "from delphi.subgraphs import get_subgraph_for_concept_pair\n", |
456 | 434 | "G = AnalysisGraph.from_statements(sts)\n",
|
457 | 435 | "merge_nodes(G, 'food_security', 'food_insecurity', same_polarity=False)\n",
|
458 | 436 | "G = get_subgraph_for_concept_pair(G, 'drought', 'food_insecurity', cutoff=2)\n",
|
|
798 | 776 | "title_cell": "Table of Contents",
|
799 | 777 | "title_sidebar": "Contents",
|
800 | 778 | "toc_cell": false,
|
801 |
| - "toc_position": {}, |
| 779 | + "toc_position": { |
| 780 | + "height": "calc(100% - 180px)", |
| 781 | + "left": "10px", |
| 782 | + "top": "150px", |
| 783 | + "width": "165px" |
| 784 | + }, |
802 | 785 | "toc_section_display": true,
|
803 | 786 | "toc_window_display": true
|
804 | 787 | }
|
|
0 commit comments