#!/usr/bin/env python # coding: utf-8 # # Backcasting Demo Notebook # # _Loren Champlin_ # # Adapted from _Adarsh Pyarelal_'s WM 12 Month Evaluation Notebook # # As always, we begin with imports, and print out the commit hash for a rendered # version of the notebook. # In[ ]: get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') get_ipython().run_line_magic('matplotlib', 'inline') from IPython.display import set_matplotlib_formats set_matplotlib_formats('retina') import numpy as np import pandas as pd from delphi.db import engine import random as rm import delphi.evaluation_port as EN import warnings warnings.filterwarnings("ignore") import logging logging.getLogger().setLevel(logging.CRITICAL) from delphi.cpp.DelphiPython import AnalysisGraph as AG, InitialBeta as IB, RNG import time import seaborn as sns import matplotlib.pyplot as plt from delphi.jupyter_tools import display import seaborn as sns from scipy import stats import matplotlib.patches as mpatches # Here I will set random seeds # In[ ]: np.random.seed(87) rm.seed(87) # In[ ]: EN.get_data_value('Net migration',year=2012,month=2, use_heuristic=True) # In[ ]: x = np.array([[1,2,2],[4,4,4],[8,3,4],[7,2,3]]) y = np.mean(x,axis=1) ax = sns.lineplot(x=range(5),y=range(5)) # In[ ]: help(mpatches.Patch) # In[ ]: query = " ".join( [ f"select * from indicator", ] ) results = engine.execute(query) list(results) # In[ ]: query = " ".join( [ f"select * from indicator", f"where `Variable` is 'Historical Production (Maize)'", ] ) results = engine.execute(query) results_df2 = pd.DataFrame(results,columns=results.keys()) results_df2