コード例 #1
0
testing_date = "2020-06-15"
testing_date_file = "".join(testing_date.split("-"))
n_days_testing_data = (pd.to_datetime(testing_date) - pd.to_datetime(prediction_date)).days
print(f"Prediction date: {prediction_date} and Testing Date: {testing_date} so " +
      f"{n_days_testing_data} days of testing data in this run")
with open(
        PATH_TO_FOLDER_DANGER_MAP + f'predicted/world_Python_{prediction_date_file}_Scenarios_since_100_cases.json',
        'rb'  # Need to read it as binary
) as json_file:
    dict_scenarios_world = json.load(json_file)

###################################################################
##### Retrieving current policies for all countries/provinces #####
###################################################################
policy_data_countries = read_measures_oxford_data(yesterday=testing_date)
policy_data_us_only = read_policy_data_us_only(filepath_data_sandbox=PATH_TO_DATA_SANDBOX)
popcountries = pd.read_csv(PATH_TO_FOLDER_DANGER_MAP + f"processed/Global/Population_Global.csv")
pastparameters = pd.read_csv(PATH_TO_FOLDER_DANGER_MAP + f"predicted/Parameters_Global_{testing_date_file}.csv")
# True if we use the Mathematica run parameters, False if we use those from Python runs
# This is because the pastparameters dataframe's columns are not in the same order in both cases

# Get the policies shifts from the CART tree to compute different values of gamma(t)
# Depending on the policy in place in the future to affect predictions
dict_normalized_policy_gamma_countries, dict_current_policy_countries = (
    get_normalized_policy_shifts_and_current_policy_all_countries(
        policy_data_countries=policy_data_countries[policy_data_countries.date <= testing_date],
        pastparameters=pastparameters,
    )
)
# Setting same value for these 2 policies because of the inherent structure of the tree
dict_normalized_policy_gamma_countries[future_policies[3]] = dict_normalized_policy_gamma_countries[future_policies[5]]
コード例 #2
0
                           future_policies, future_times)
import yaml
import os
import matplotlib.pyplot as plt

with open("config.yml", "r") as ymlfile:
    CONFIG = yaml.load(ymlfile, Loader=yaml.BaseLoader)
CONFIG_FILEPATHS = CONFIG["filepaths"]
USER_RUNNING = "omar"
yesterday = "".join(str(datetime.now().date() - timedelta(days=1)).split("-"))
#%%
# TODO: Find a way to make these paths automatic, whoever the user is...
PATH_TO_FOLDER_DANGER_MAP = CONFIG_FILEPATHS["danger_map"][USER_RUNNING]
PATH_TO_WEBSITE_PREDICTED = CONFIG_FILEPATHS["danger_map"][USER_RUNNING]
policy_data_countries = read_measures_oxford_data(yesterday)
policy_data_us_only = read_policy_data_us_only(
    filepath_data_sandbox=CONFIG_FILEPATHS["data_sandbox"][USER_RUNNING])
popcountries = pd.read_csv(PATH_TO_FOLDER_DANGER_MAP +
                           f"processed/Global/Population_Global.csv")
pastparameters = pd.read_csv(PATH_TO_FOLDER_DANGER_MAP +
                             f"predicted/Parameters_Global_{yesterday}.csv")
if pd.to_datetime(yesterday) < pd.to_datetime(date_MATHEMATICA):
    param_MATHEMATICA = True
else:
    param_MATHEMATICA = False
# True if we use the Mathematica run parameters, False if we use those from Python runs
# This is because the pastparameters dataframe's columns are not in the same order in both cases

# Get the policies shifts from the CART tree to compute different values of gamma(t)
# Depending on the policy in place in the future to affect predictions
dict_normalized_policy_gamma_countries, dict_current_policy_countries = (
    get_normalized_policy_shifts_and_current_policy_all_countries(
コード例 #3
0
                          get_initial_conditions, mape,
                          read_policy_data_us_only,
                          get_normalized_policy_shifts_and_current_policy)
import dateutil.parser as dtparser
import os
import matplotlib.pyplot as plt

yesterday = "".join(str(datetime.now().date() - timedelta(days=4)).split("-"))
# TODO: Find a way to make these paths automatic, whoever the user is...
PATH_TO_FOLDER_DANGER_MAP = (
    "E:/Github/covid19orc/danger_map/"
    # "/Users/hamzatazi/Desktop/MIT/999.1 Research Assistantship/" +
    # "4. COVID19_Global/covid19orc/danger_map/"
)
PATH_TO_WEBSITE_PREDICTED = ("E:/Github/website/data/")
policy_data_us_only = read_policy_data_us_only()
#os.chdir(PATH_TO_FOLDER_DANGER_MAP)
popcountries = pd.read_csv(PATH_TO_FOLDER_DANGER_MAP +
                           f"processed/Global/Population_Global.csv")
pastparameters = pd.read_csv(PATH_TO_FOLDER_DANGER_MAP +
                             f"predicted/Parameters_Global_{yesterday}.csv")
param_MATHEMATICA = True
# True if we use the Mathematica run parameters, False if we use those from Python runs
# This is because the pastparameters dataframe's columns are not in the same order in both cases

# Get the policies shifts from the CART tree to compute different values of gamma(t)
# Depending on the policy in place in the future to affect predictions
dict_policies_shift, dict_last_policy = get_normalized_policy_shifts_and_current_policy(
    policy_data_us_only=policy_data_us_only,
    pastparameters=pastparameters,
)