implemented voila dashboard and setup

This commit is contained in:
seangreaves
2022-12-31 13:51:42 +00:00
parent 3371acdbcc
commit 7f0e8be388
21 changed files with 3045 additions and 1263 deletions

172
notebooks/quickstart.ipynb Normal file
View File

@@ -0,0 +1,172 @@
{
"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": [
"from sugartrail import mapview, api, base\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",
"# import pickle\n",
"\n",
"# with open('../assets/networks/domain_corp_network.pickle', 'rb') as handle:\n",
"# network = pickle.load(handle)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "89b0082a",
"metadata": {},
"outputs": [],
"source": [
"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 = 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 = 3\n",
"network = 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 = mapview.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.9.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}