Merge branch 'gridification' into main
Some checks failed
CI / fast (without R) (push) Has been cancelled
CI / slow (with R) (push) Has been cancelled

This commit is contained in:
Alexander Hess 2021-02-04 15:39:46 +01:00
commit d494a7908b
Signed by: alexander
GPG key ID: 344EA5AB10D868E0
14 changed files with 614095 additions and 5 deletions

View file

@ -114,7 +114,7 @@
" shutil.rmtree(r_libs_path)\n", " shutil.rmtree(r_libs_path)\n",
"except FileNotFoundError:\n", "except FileNotFoundError:\n",
" pass\n", " pass\n",
"os.mkdir(r_libs_path)" "os.makedirs(r_libs_path)"
] ]
}, },
{ {

View file

@ -192,7 +192,7 @@
"source": [ "source": [
"%cd -q ..\n", "%cd -q ..\n",
"!alembic upgrade f11cd76d2f45\n", "!alembic upgrade f11cd76d2f45\n",
"%cd -q notebooks" "%cd -q research"
] ]
}, },
{ {
@ -7647,7 +7647,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.8.5" "version": "3.8.6"
} }
}, },
"nbformat": 4, "nbformat": 4,

View 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
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,7 @@
The purpose of this module is to import all the R packages that are installed 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. 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. R dependencies on a Ubuntu/Debian based system.
""" """
@ -24,5 +24,5 @@ try: # noqa:WPS229
rpackages.importr('zoo') rpackages.importr('zoo')
except rpackages.PackageNotInstalledError: # pragma: no cover 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 raise rpackages.PackageNotInstalledError(msg) from None