{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Backcasting Demo Notebook\n", "\n", "_Loren Champlin_\n", "\n", "Adapted from _Adarsh Pyarelal_'s WM 12 Month Evaluation Notebook \n", "\n", "As always, we begin with imports, and print out the commit hash for a rendered\n", "version of the notebook." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", "%matplotlib inline\n", "from IPython.display import set_matplotlib_formats\n", "set_matplotlib_formats('retina')\n", "import numpy as np\n", "import pandas as pd\n", "from delphi.db import engine\n", "import random as rm\n", "import delphi.evaluation_port as EN\n", "import warnings\n", "warnings.filterwarnings(\"ignore\")\n", "import logging\n", "logging.getLogger().setLevel(logging.CRITICAL)\n", "from delphi.cpp.DelphiPython import AnalysisGraph as AG, InitialBeta as IB, RNG\n", "import time\n", "import seaborn as sns\n", "import matplotlib.pyplot as plt\n", "from delphi.jupyter_tools import display\n", "import seaborn as sns\n", "from scipy import stats\n", "import matplotlib.patches as mpatches" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here I will set random seeds" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "np.random.seed(87)\n", "rm.seed(87)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "EN.get_data_value('Net migration',year=2012,month=2, use_heuristic=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x = np.array([[1,2,2],[4,4,4],[8,3,4],[7,2,3]])\n", "y = np.mean(x,axis=1)\n", "\n", "ax = sns.lineplot(x=range(5),y=range(5))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "help(mpatches.Patch)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "query = \" \".join(\n", " [\n", " f\"select * from indicator\",\n", " ]\n", " )\n", "\n", "results = engine.execute(query)\n", "\n", "list(results)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "query = \" \".join(\n", " [\n", " f\"select * from indicator\",\n", " f\"where `Variable` is 'Historical Production (Maize)'\",\n", " ]\n", " )\n", "\n", "results = engine.execute(query)\n", "\n", "results_df2 = pd.DataFrame(results,columns=results.keys())\n", "\n", "\n", "results_df2" ] } ], "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.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }