Run the gridification script
This commit is contained in:
parent
28a7c7451c
commit
1e263a4b98
1 changed files with 168 additions and 0 deletions
168
research/02_gridification.ipynb
Normal file
168
research/02_gridification.ipynb
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# Gridification"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"This notebook runs the gridification script and creates all the pixels in the database."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"\u001b[32murban-meal-delivery\u001b[0m, version \u001b[34m0.3.0\u001b[0m\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"!umd --version"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### Upgrade Database Schema"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"This database migration also de-duplicates redundant addresses and removes obvious outliers."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"%cd -q .."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"INFO [alembic.runtime.migration] Context impl PostgresqlImpl.\n",
|
||||||
|
"INFO [alembic.runtime.migration] Will assume transactional DDL.\n",
|
||||||
|
"INFO [alembic.runtime.migration] Running upgrade f11cd76d2f45 -> 888e352d7526, Add pixel grid.\n",
|
||||||
|
"INFO [alembic.runtime.migration] Running upgrade 888e352d7526 -> e40623e10405, Add demand forecasting.\n",
|
||||||
|
"INFO [alembic.runtime.migration] Running upgrade e40623e10405 -> 26711cd3f9b9, Add confidence intervals to forecasts.\n",
|
||||||
|
"INFO [alembic.runtime.migration] Running upgrade 26711cd3f9b9 -> e86290e7305e, Remove orders from restaurants with invalid location ...\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"!alembic upgrade e86290e7305e"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### Create the Grids"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"Put all restaurant locations in pixels."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"3 cities retrieved from the database\n",
|
||||||
|
"\n",
|
||||||
|
"Creating grids for Lyon\n",
|
||||||
|
"Creating grid with a side length of 707 meters\n",
|
||||||
|
" -> created 62 pixels\n",
|
||||||
|
"Creating grid with a side length of 1000 meters\n",
|
||||||
|
" -> created 38 pixels\n",
|
||||||
|
"Creating grid with a side length of 1414 meters\n",
|
||||||
|
" -> created 24 pixels\n",
|
||||||
|
"=> assigned 358 out of 48058 addresses in Lyon\n",
|
||||||
|
"\n",
|
||||||
|
"Creating grids for Paris\n",
|
||||||
|
"Creating grid with a side length of 707 meters\n",
|
||||||
|
" -> created 199 pixels\n",
|
||||||
|
"Creating grid with a side length of 1000 meters\n",
|
||||||
|
" -> created 111 pixels\n",
|
||||||
|
"Creating grid with a side length of 1414 meters\n",
|
||||||
|
" -> created 66 pixels\n",
|
||||||
|
"=> assigned 1133 out of 108135 addresses in Paris\n",
|
||||||
|
"\n",
|
||||||
|
"Creating grids for Bordeaux\n",
|
||||||
|
"Creating grid with a side length of 707 meters\n",
|
||||||
|
" -> created 30 pixels\n",
|
||||||
|
"Creating grid with a side length of 1000 meters\n",
|
||||||
|
" -> created 22 pixels\n",
|
||||||
|
"Creating grid with a side length of 1414 meters\n",
|
||||||
|
" -> created 15 pixels\n",
|
||||||
|
"=> assigned 123 out of 21742 addresses in Bordeaux\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"!umd gridify"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"%cd -q research"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"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.8.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 4
|
||||||
|
}
|
Loading…
Reference in a new issue