# third_algorithm_label = 'Half-log-scaled SE' np.random.seed(seed) x_tr = np.random.rand(dim, num) if dim == 2: x_1 = np.linspace(0, 1, test_density) x_2 = np.linspace(0, 1, test_density) x_1, x_2 = np.meshgrid(x_1, x_2) x_test = np.array(list(zip(x_1.reshape(-1).tolist(), x_2.reshape(-1).tolist()))) x_test = x_test.T else: x_test = np.random.rand(dim, test_density**2) print("Generating Data") y_tr, y_test = gp.generate_data(x_tr, x_test, seed=seed) print("Data generated") # First method model_params = np.array([np.log(2.2), np.log(1.73), np.log(0.2)]) model_covariance_obj = ExpScaledSquaredExponential(model_params) # model_params = np.array([2.2, 1.73, 0.2]) # model_covariance_obj = SquaredExponential(model_params) first_gp = GaussianProcess(model_covariance_obj, lambda x: 0, 'class') w_a_list, time_a_list = first_gp.find_hyper_parameters(x_tr, y_tr, max_iter=iterations_1, alternate=True) w_a_list = [np.exp(w) for w in w_a_list] w_a_opt = w_a_list[-1] w_a_list = w_a_list[:plot_iterations_1]
np.random.seed(seed) x_tr = np.random.rand(dim, num) if dim == 2: x_1 = np.linspace(0, 1, test_density) x_2 = np.linspace(0, 1, test_density) x_1, x_2 = np.meshgrid(x_1, x_2) x_test = np.array( list(zip(x_1.reshape(-1).tolist(), x_2.reshape(-1).tolist()))) x_test = x_test.T else: x_test = np.random.rand(dim, test_density**2) print("Generating Data") y_tr, y_test = gp.generate_data(x_tr, x_test, seed=seed) print("Data generated") # First method model_params = np.array([np.log(2.2), np.log(1.73), np.log(0.2)]) model_covariance_obj = ExpScaledSquaredExponential(model_params) # model_params = np.array([2.2, 1.73, 0.2]) # model_covariance_obj = SquaredExponential(model_params) first_gp = GaussianProcess(model_covariance_obj, lambda x: 0, 'class') w_a_list, time_a_list = first_gp.find_hyper_parameters(x_tr, y_tr, max_iter=iterations_1, alternate=True) w_a_list = [np.exp(w) for w in w_a_list]