mirror of
https://github.com/bellingcat/sugartrail.git
synced 2026-06-07 19:18:30 +03:00
170 lines
4.2 KiB
Plaintext
170 lines
4.2 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "b6926e35",
|
|
"metadata": {},
|
|
"source": [
|
|
"*Quickstart hands-on exercise. For in-depth intro checkout Tutorial 1:*"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "f17ebdd2",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import sugartrail\n",
|
|
"from ipywidgets import VBox, HBox"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "d5f9b6ad",
|
|
"metadata": {},
|
|
"source": [
|
|
"Insert a valid [Companies House Public Data API key](https://developer.company-information.service.gov.uk/get-started/) as `username` string value below. If you don't want to use the API and would prefer loading a pre-built network, uncomment and run the cell below and then run the final cell to build and load the map. "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "4a9639e6",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# network build from Domain Foundation, company_id = \"11951034\"\n",
|
|
"# network = sugartrail.base.Network(file=f'{sugartrail.const.networks_path}quickstart_a.json')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "89b0082a",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"sugartrail.api.basic_auth.username = \"\""
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "63220f29",
|
|
"metadata": {},
|
|
"source": [
|
|
"Enter the company number (as string) for a company you would like to explore. Example value is provided: "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "8aca6a54",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"company_id = \"11951034\"\n",
|
|
"network = sugartrail.base.Network(company_id=company_id)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "7de31e72",
|
|
"metadata": {
|
|
"tags": [
|
|
"5"
|
|
]
|
|
},
|
|
"source": [
|
|
"Perform `n` number of hops (3 or less at first is advised to keep the network manageable in size):"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "d80be86d",
|
|
"metadata": {
|
|
"tags": [
|
|
"6"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"n = 4\n",
|
|
"network = sugartrail.base.Network(company_id=company_id)\n",
|
|
"network.perform_hop(n)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "4481c80d",
|
|
"metadata": {},
|
|
"source": [
|
|
"Now lets visualise the connections:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "022f026e",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"network.run_map_preprocessing()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "01dca0cf",
|
|
"metadata": {
|
|
"scrolled": false,
|
|
"tags": [
|
|
"7"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"map_data,path_table = sugartrail.mapvis.build_map(network) \n",
|
|
"hbox = HBox([path_table])\n",
|
|
"vbox = VBox([map_data, hbox])\n",
|
|
"vbox"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "457bf4d0",
|
|
"metadata": {},
|
|
"source": [
|
|
"Each marker represents a company in the network. Green markers represent active companies based at the address, red markers represent active companies no longer based at the address and black markers represent dissolved companies once based at the address. \n",
|
|
"\n",
|
|
"Select a marker to display additional information: \n",
|
|
"- pop-up with the selected company's name and address\n",
|
|
"- table containing the most efficient paths from the origin to the selected company\n",
|
|
"- antpaths for each company in the network. Red antpath represents the path through all the historic addresses for the selected company. Black antpath represents the path from the network origin through all the addresses in the path to the selected company as displayed in the table. "
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"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.10.14"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|