예제 #1
0
    d.NewCases.mask[i, c_s:] = True


if __name__ == "__main__":

    class ResultsObject():
        def __init__(self, indxs, trace):
            self.CMReduction = trace.CMReduction
            self.RegionLogR = trace.RegionLogR[:, indxs]
            self.InfectedCases = trace.InfectedCases[:, indxs, :]
            self.InfectedDeaths = trace.InfectedDeaths[:, indxs, :]
            self.ExpectedCases = trace.ExpectedCases[:, indxs, :]
            self.ExpectedDeaths = trace.ExpectedDeaths[:, indxs, :]
            self.Phi = trace.Phi_1

    dp = DataPreprocessor(min_confirmed=100, drop_HS=True)
    data = dp.preprocess_data("notebooks/final_data/data_final.csv")

    HO_rs = ["DE", "PT", "CZ", "PL", "MX", "NL"]
    indxs = [data.Rs.index(rg) for rg in HO_rs]
    unmask_all(data)
    for region in HO_rs:
        mask_region(data, region)

    print(f"Growth Noise {args.g}")
    with cm_effect.models.CMCombined_Final_V3(data, None) as model:
        model.DailyGrowthNoise = args.g
        model.build_model()

    with model.model:
        model.trace = pm.sample(args.nS, chains=args.nC, target_accept=0.95)
예제 #2
0
        if "Phi" in trace.varnames:
            self.Phi = trace.Phi
        elif "Phi_1" in trace.varnames:
            self.Phi = trace.Phi_1


if __name__ == "__main__":
    folds = [['FR', 'GR', 'NL', 'BA', 'LV'], ['SE', 'DE', 'LT', 'MY', 'BG'],
             ['FI', 'DK', 'CZ', 'RS', 'BE'], ['NO', 'SK', 'IL', 'CH', 'ES'],
             ['ZA', 'MX', 'IT', 'IE', 'GE'], ['RO', 'PL', 'MA', 'HU', 'SI'],
             ['NZ', 'SG', 'PT', 'HR', 'EE']]

    eval_fold = ['AL', 'AT', 'GB', 'AD', 'IS', 'MT']

    dp = DataPreprocessor()
    for fold_i, fold in enumerate(folds):
        data = dp.preprocess_data(
            "notebooks/double-entry-data/double_entry_final.csv",
            last_day="2020-05-30",
            schools_unis="whoops")
        data.mask_reopenings()

        r_is = []
        for rg in fold:
            c_s, d_s = mask_region(data, rg)
            r_is.append(data.Rs.index(rg))

        with cm_effect.models.CMCombined_Final_DifEffects(data, None) as model:
            model.DailyGrowthNoise = args.growth_noise
            model.RegionVariationNoise = args.country_noise
예제 #3
0
        if "Phi" in trace.varnames:
            self.Phi = trace.Phi
        elif "Phi_1" in trace.varnames:
            self.Phi = trace.Phi_1


if __name__ == "__main__":
    folds = [['DE', 'HU', 'FI', 'IE', 'RS', 'BE'],
             ['DK', 'GR', 'NO', 'FR', 'RO', 'MA'],
             ['ES', 'CZ', 'NL', 'CH', 'PT', 'AT'],
             ['IL', 'SE', 'IT', 'MX', 'GB', 'PL']]

    fold_rs = folds[args.fold]

    dp = DataPreprocessor(drop_HS=True)
    data = dp.preprocess_data("notebooks/final_data/data_final.csv")

    major_interventions = ["School Closure", "Stay Home Order", "Some Businesses Suspended",
                           "Most Businesses Suspended", "Gatherings <10", "Gatherings <1000", "Gatherings <100"]
    minor_interventions = ["Mask Wearing", "Symptomatic Testing"]

    ActiveCMs = copy.deepcopy(data.ActiveCMs)

    maj_indxs = np.array([data.CMs.index(x) for x in major_interventions])
    min_indxs = np.array([data.CMs.index(x) for x in minor_interventions])

    nRs, nCMs, nDs = ActiveCMs.shape

    for r in range(nRs):
        maj_active = np.sum(data.ActiveCMs[r, maj_indxs, :], axis=0)