コード例 #1
0
def test_cpp_extensions_preds():
    statements = [(
        ("large", -1, "UN/entities/human/financial/economic/inflation"),
        ("small", 1, "UN/events/human/human_migration"),
    )]
    G = AnalysisGraph.from_causal_fragments(statements)
    G.map_concepts_to_indicators()
    G["UN/events/human/human_migration"].replace_indicator(
        "Net migration", "New asylum seeking applicants", "UNHCR")
    G.to_png()

    # Now we can specify how to initialize betas. Posible values are:
    # InitialBeta.ZERO
    # InitialBeta.ONE
    # InitialBeta.HALF
    # InitialBeta.MEAN
    # InitialBeta.RANDOM - A random value between [-1, 1]
    G.train_model(2015,
                  1,
                  2015,
                  12,
                  10,
                  10,
                  initial_beta=InitialBeta.ZERO,
                  use_continuous=False)
    preds = G.generate_prediction(2015, 1, 2016, 12)
    pred_plot(preds, "New asylum seeking applicants", save_as="pred_plot.pdf")
コード例 #2
0
def test_pred_compare(G_unit):

    EN.train_model(G_unit, 2015, 1, 2015, 12, 1000, 1000, k=1)
    EN.generate_predictions(G_unit, 2016, 1, 2016, 12)

    pred_df = EN.mean_pred_to_df(G_unit, "Net migration", true_vals=True)

    print(pred_df)

    EN.pred_plot(G_unit, "Net migration", plot_type="Comparison")
コード例 #3
0
def test_pred(G_unit):

    EN.train_model(G_unit, 2015, 1, 2015, 12, 1000, 1000, k=1)
    EN.generate_predictions(G_unit, 2016, 1, 2016, 12)
    pred = EN.pred_to_array(G_unit, "Net migration")
    print(pred)

    pred_df = EN.mean_pred_to_df(G_unit, "Net migration")

    print(pred_df)

    EN.pred_plot(G_unit, "Net migration")
コード例 #4
0
    G.parameterize("South Sudan", "Jonglei", "", 2017, 4, {})
    ind = G[
        "wm/concept/indicator_and_reported_property/agriculture/Crop_Production"].get_indicator(
            "Average Harvested Weight at Maturity (Maize)")

    draw_CAG(G)
    G.train_model(
        2014,
        6,
        2016,
        3,
        country="South Sudan",
        res=20,
        burn=100,
        use_heuristic=False,
    )
    G.set_default_initial_state()
    G.s0[1] = 0.1
    preds = G.generate_prediction(2016, 3, 2016, 7)
    # preds = G.generate_prediction(2018, 1, 2018, 2)
    EN.pred_plot(
        preds,
        "IPC Phase Classification",
        0.95,
        plot_type="Prediction",
        show_rmse=True,
        show_training_data=True,
        use_heuristic_for_true=False,
        save_as="Oct2019EvalPred.png",
    )
コード例 #5
0
def test_pred_error(G_unit):

    EN.train_model(G_unit, 2015, 1, 2015, 12, 1000, 1000, k=1)
    EN.generate_predictions(G_unit, 2016, 1, 2016, 12)

    EN.pred_plot(G_unit, "Net migration", plot_type="Error")