Merge branch 'gridification' into main
This commit is contained in:
commit
d494a7908b
14 changed files with 614095 additions and 5 deletions
|
@ -114,7 +114,7 @@
|
|||
" shutil.rmtree(r_libs_path)\n",
|
||||
"except FileNotFoundError:\n",
|
||||
" pass\n",
|
||||
"os.mkdir(r_libs_path)"
|
||||
"os.makedirs(r_libs_path)"
|
||||
]
|
||||
},
|
||||
{
|
|
@ -192,7 +192,7 @@
|
|||
"source": [
|
||||
"%cd -q ..\n",
|
||||
"!alembic upgrade f11cd76d2f45\n",
|
||||
"%cd -q notebooks"
|
||||
"%cd -q research"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -7647,7 +7647,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.5"
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
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
|
||||
}
|
356
research/03_grid_visualizations.ipynb
Normal file
356
research/03_grid_visualizations.ipynb
Normal file
File diff suppressed because one or more lines are too long
82173
research/visualizations/addresses_in_bordeaux_by_zip_code.html
Normal file
82173
research/visualizations/addresses_in_bordeaux_by_zip_code.html
Normal file
File diff suppressed because it is too large
Load diff
108381
research/visualizations/addresses_in_lyon_by_zip_code.html
Normal file
108381
research/visualizations/addresses_in_lyon_by_zip_code.html
Normal file
File diff suppressed because it is too large
Load diff
332859
research/visualizations/addresses_in_paris_by_zip_code.html
Normal file
332859
research/visualizations/addresses_in_paris_by_zip_code.html
Normal file
File diff suppressed because it is too large
Load diff
3357
research/visualizations/restaurants_in_bordeaux.html
Normal file
3357
research/visualizations/restaurants_in_bordeaux.html
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
9243
research/visualizations/restaurants_in_lyon.html
Normal file
9243
research/visualizations/restaurants_in_lyon.html
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
30195
research/visualizations/restaurants_in_paris.html
Normal file
30195
research/visualizations/restaurants_in_paris.html
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
|||
The purpose of this module is to import all the R packages that are installed
|
||||
into a sub-folder (see `config.R_LIBS_PATH`) in the project's root directory.
|
||||
|
||||
The Jupyter notebook "research/r_dependencies.ipynb" can be used to install all
|
||||
The Jupyter notebook "research/00_r_dependencies.ipynb" can be used to install all
|
||||
R dependencies on a Ubuntu/Debian based system.
|
||||
"""
|
||||
|
||||
|
@ -24,5 +24,5 @@ try: # noqa:WPS229
|
|||
rpackages.importr('zoo')
|
||||
|
||||
except rpackages.PackageNotInstalledError: # pragma: no cover
|
||||
msg = 'See the "research/r_dependencies.ipynb" notebook!'
|
||||
msg = 'See the "research/00_r_dependencies.ipynb" notebook!'
|
||||
raise rpackages.PackageNotInstalledError(msg) from None
|
||||
|
|
Loading…
Reference in a new issue