예제 #1
0
def ex3_grand_position(source, destination, recall):

    file_params = {
        "agents": [10, 20, 30],
        "jump_rate": [5, 10, 20],
        # "source" : "/home/rob/dust/Projects/ABM_DA/experiments/ukf_experiments/ukf_results/agg_ukf_",
        "source": source,
        "destination": destination
    }

    "initialise plot for observed/unobserved agents"
    g_plts = depickle.grand_plots(file_params,
                                  True,
                                  restrict=None,
                                  observed=True)

    if not recall:
        "make dictionary"
        L2 = g_plts.data_extractor()
        "make pandas dataframe for seaborn"
        error_frame = g_plts.data_framer(L2)
        error_frame.to_pickle(
            os.path.split(source)[:-1][0] + "/rjukf_locations_frame.pkl")
    else:
        error_frame = pd.read_pickle(
            os.path.split(source)[:-1][0] + "/rjukf_locations_frame.pkl")

    "make choropleth numpy array"
    error_array = g_plts.choropleth_array(error_frame)
    "make choropleth"
    g_plts.choropleth_plot(error_array, "Numbers of Agents",
                           "Reversible Jump Window", "")
    "make boxplot"
    g_plts.boxplot(error_frame, "Reversible Jump Window",
                   "Grand Median L2s (log(metres))", "")
예제 #2
0
def ex1_grand_no_split(source, destination, recall):
    """ Same as ex1_grand but doesn't split into observed/unobserved agents
    

    Parameters
    ----------
    source, destination : str
        `source` of experiment pickles and `destination` of the resulting plots
    recall : bool
        `recall` previously aggregated pickles from a np/pandas frame for speed?

    Returns
    -------
    None.

    """
    prefix = "ukf*"
    
    file_params = {
        "agents":  [10, 20, 30],
        "prop": [0.25, 0.5, 0.75, int(1)],
        # "source" : "/home/rob/dust/Projects/ABM_DA/experiments/ukf_experiments/ukf_results/agg_ukf_",
        "source": source,
        "destination": destination
    }

    "initialise plot for observed/unobserved agents"
    g_plts = grand_plots(file_params, True, restrict=None, observed=True)
    "make dictionary"
    with HiddenPrints():
        L2 = g_plts.data_extractor()
        
    if not recall:
        L2 = g_plts.data_extractor()
        "make pandas dataframe for seaborn"
        error_frame = g_plts.data_framer(L2)
        "make choropleth numpy array"
        error_array = g_plts.choropleth_array(error_frame)
        error_frame.to_pickle(source + "Mixed_distance_error_array.pkl")
        np.save(source + "Mixed_distance_error_array", error_array)
    else:
        error_array = np.load(source + "Mixed_distance_error_array.npy")
        error_frame = pd.read_pickle(source + "Mixed_distance_error_array.pkl")
        
    "make pandas dataframe for seaborn"
    error_frame = g_plts.data_framer(L2)
    "make choropleth numpy array"
    error_array = g_plts.choropleth_array(error_frame)
    "make choropleth"
    g_plts.choropleth_plot(error_array, "Numbers of Agents",
                           "Proportion Observed", "Mixed")
    "make boxplot"
    g_plts.boxplot(error_frame, "Proportion Observed",
                   "Grand Median L2s", "Mixed")
예제 #3
0
def ex1_grand(source, destination, recall):
    """ main function for parsing experiment 1 results into summary plots
    

    Parameters
    ----------
    source, destination : str
        `source` of experiment pickles and `destination` of the resulting plots
    recall : bool
        `recall` previously aggregated pickles from a np/pandas frame for speed?

    Returns
    -------
    None.

    """
    prefix = "ukf*"
    
    file_params = {
        "agents":  [10, 20, 30],
        "prop": [0.25, 0.5, 0.75, int(1)],
        # "source" : "/home/rob/dust/Projects/ABM_DA/experiments/ukf_experiments/ukf_results/agg_ukf_",
        "source": source + prefix,
        "destination": destination,
    }
    
    "plot observed/unobserved plots"
    obs_bools = [True, False]
    obs_titles = ["Observed", "Unobserved"]
    for i in range(len(obs_bools)):
        "initialise plot for observed/unobserved agents"
        g_plts = grand_plots(file_params, True, restrict=ex1_restrict,
                             observed=obs_bools[i])
        "make dictionary"
        if not recall:
            L2 = g_plts.data_extractor()
            "make pandas dataframe for seaborn"
            error_frame = g_plts.data_framer(L2)
            "make choropleth numpy array"
            error_array = g_plts.choropleth_array(error_frame)
            np.save(source + obs_titles[i] + "_distance_error_array", error_array)
            error_frame.to_pickle(source + obs_titles[i] + "_distance_error_array.pkl")
        else:
            error_frame = pd.read_pickle(source + obs_titles[i] + "_distance_error_array.pkl")
            error_array = np.load(source + obs_titles[i] + "_distance_error_array.npy")
            
        "make choropleth"
        g_plts.choropleth_plot(error_array, "Numbers of Agents", "Proportion Observed",
                               obs_titles[i])
        "make boxplot"
        g_plts.boxplot(error_frame, "Proportion Observed", "Grand Median L2s",
                       obs_titles[i])
예제 #4
0
def ex2_grand(source, destination, recall):
    """ main function for parsing experiment 2 results into summary plots
    

    Parameters
    ----------
    source, destination : str
        `source` of experiment pickles and `destination` of the resulting plots
    recall : bool
        `recall` previously aggregated pickles from a np/pandas frame for speed?

    Returns
    -------
    None.

    """
    
    prefix = "agg*"
    file_params = {
        "agents":  [10, 20],
        "bin": [10, 25],
        # "source" : "/home/rob/dust/Projects/ABM_DA/experiments/ukf_experiments/ukf_results/agg_ukf_",
        "source": source,
        "destination": destination,
    }

    "init plot class"
    g_plts = grand_plots(file_params, True)
    "make dictionary"
    
    if not recall:
        L2 = g_plts.data_extractor()
        "make pandas dataframe for seaborn"
        error_frame = g_plts.data_framer(L2)
        "make choropleth numpy array"
        error_array = g_plts.choropleth_array(error_frame)
        error_frame.to_pickle(source + "Aggregate_distance_error_array.pkl")
        np.save(source + "Aggregate_distance_error_array", error_array)
    else:
        error_array = np.load(source + "Aggregate_distance_error_array.npy")
        error_frame = pd.read_pickle(source + "Aggregate_distance_error_array.pkl")
        
    with HiddenPrints():
        L2 = g_plts.data_extractor()
        
    "make choropleth"
    g_plts.choropleth_plot(error_array, "Numbers of Agents",
                           "Proportion Observed", "Aggregate")
    "make boxplot"
    g_plts.boxplot(error_frame, "Grid Square Size",
                   "Grand Median L2s", "Aggregate")
예제 #5
0
def ex3_grand_gates(source, destination, recall):
    """ main function for parsing experiment 3 results into summary plots
    

    Parameters
    ----------
    source, destination : str
        `source` of experiment pickles and `destination` of the resulting plots
    recall : bool
        `recall` previously aggregated pickles from a np/pandas frame for speed?

    Returns
    -------
    None.

    """
    file_params = {
        "agents": [10, 20, 30],
        "jump_rate": [5, 10, 20],
        "source": source,
        "destination": destination
    }

    "initialise plot for observed/unobserved agents"
    g_plts = depickle.grand_plots(file_params, True)
    "make dictionary"
    if not recall:
        gate_distances = g_plts.gates_extractor()
        data_frame = g_plts.gates_data_frame(gate_distances)
        data_frame.to_pickle(
            os.path.split(source)[:-1][0] + "/rjukf_gates_frame.pkl")

    else:
        data_frame = pd.read_pickle(
            os.path.split(source)[:-1][0] + "/rjukf_gates_frame.pkl")
    "make pandas dataframe for seaborn"
    "make choropleth numpy array"
    g_plts.gates_data_lineplot(data_frame, "Time", "Error (Number of Gates)",
                               "rjmcmc_UKF_")