def see_what_its_doing_1d(): """ Graphs all points and interpolates unknown points, useful for visualizing Gaussian Interpolation and affects of kernals :return: """ all_points = create_points_with_random_pollution_1d(100, 100, 10) picked_points = pick_uniform_random_points(all_points, 20) interpolated_points = interpolate_unknown_points(picked_points, all_points) picked_x = [] picked_pollution = [] for label, point in picked_points.items(): picked_x.append(label) picked_pollution.append(point.get_pollution_value()) interp_x = [] inter_pollution = [] for label, point in interpolated_points.items(): if not label in picked_x: interp_x.append(label) inter_pollution.append(point.get_pollution_value()) plt.plot(picked_x, picked_pollution, "ro", interp_x, inter_pollution, "go") plt.xlabel("Point Label") plt.ylabel("Pollution Value") plt.show()
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
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)