Esempio n. 1
0
def run_interpolation_with_various_betas(points,
                                         kernel=RBF(10, (1e-2, 1e2)) * C(1)):
    """
    Runs Interpolation with number of picked points(beta) from 1 to all points-1 picked and using uniform distribution in
    the picking in 1 Dimesnsion
    """

    rmse_data = []

    for i in range(
            1, len(points)
    ):  # runs through all number of picked points starting at 1 and ending with all points picked-1
        sum_rmse = 0
        for j in range(
                0, 3
        ):  # runs every interpolation with a certain beta 5 times and averages the results
            picked_points = pick_uniform_random_points(points, i)
            interpolated_points = interpolate_unknown_points(
                picked_points, points, kernel)
            sum_rmse = sum_rmse + root_mean_square_error(interpolated_points)
        rmse_data.append(sum_rmse / 5)

    plot_numbers(rmse_data, range(1, len(points)))

    return rmse_data
Esempio n. 2
0
def run_experiment_with_various_length_scales_log(bottom_bound, top_bound,
                                                  side_length, mean, std,
                                                  pick_number, number_of_maps):
    """
        Experiment to see rmse of cheating and not cheating regreassion on varous length scales (traverses by powers of 10)  in 2D. Uses uniform point selection and RBF kernel
        :param bottom_bound: bottom bound of length scale
        :param top_bound: top bound of length scale not inclusive
        :param side_length: number of points on one side of the square of points
        :param mean: Mean pollution value to be set
        :param std: Standard Deviation
        :param pick_number: the Beta (the number of points to select to be measured)
        :param number_of_maps: Number of trials for each length scale
        :return:
        """
    not_cheating_data = []
    cheating_data = []
    length_scale = bottom_bound
    length_scale_list = []
    while length_scale <= top_bound:  # runs through each length scale
        points = create_points_with_spatially_correlated_pollution_2d(
            side_length, mean, std, length_scale,
            number_of_maps)  # Creates all points
        picked_points = pick_uniform_random_points_on_map_of_maps(
            points, pick_number, 0, std)  # Picks points to be measured
        interpolated_points = interpolate_unknown_points_of_a_map_of_maps_of_points(
            picked_points,
            points,
            # Interpolates using noncheating method
            RBF(np.random.randint(1e-05, 100 + 1)),
            fixed=False)

        not_cheating_data.append(
            average_rmse_of_maps(interpolated_points)
        )  # adds average rms of all the trials for the noncheating method
        interpolated_points = interpolate_unknown_points_of_a_map_of_maps_of_points(
            picked_points,
            points,
            # Interpolates using cheating method
            RBF(length_scale, ),
            fixed=True)

        cheating_data.append(
            average_rmse_of_maps(interpolated_points)
        )  # adds average rmse of all the trials for the cheating method
        length_scale_list.append(length_scale)
        length_scale = length_scale * 10

    plot_numbers(
        length_scale_list,
        not_cheating_data,
        length_scale_list,
        cheating_data,
        # Plots the data Red is not cheating, Green Cheating
        "Length Scale",
        "RMSE",
        x_log_scale=True)
Esempio n. 3
0
def run_interpolations_with_random_betas_1d():
    """
    Runs Interpolation with random picking of the value of Beta
    """
    rmse_values = []
    picked_points_values = []
    number_of_times = 100  # this will be the number of points displayed on the graph
    random = np.random.default_rng()

    for i in range(0, number_of_times):
        test_points = create_points_with_random_pollution_1d(100, 100, 10)
        test_picked_points = pick_uniform_random_points(
            test_points,
            random.integers(1, 100))  # picks a random number of known points
        test_interpolated_points = interpolate_unknown_points(
            test_picked_points, test_points)
        test_rmse = root_mean_square_error(test_interpolated_points)
        rmse_values.append(test_rmse)
        picked_points_values.append(len(test_picked_points))

    plot_numbers(rmse_values, picked_points_values)