예제 #1
0
 def test_bfgs_parameter_optimization_01(self):
     input_array = np.array([[0, 1], [1, 4], [2, 9], [3, 16], [4, 25],
                             [5, 36], [6, 49], [7, 64], [8, 81], [9, 100]])
     x = input_array[:, 0]
     y = input_array[:, 1]
     x_vector = np.zeros((x.shape[0], 3))
     x_vector[:, 0] = x[:, ]**2
     x_vector[:, 1] = x[:, ]
     x_vector[:, 2] = 1
     expected_value = np.array([[1.], [2.], [1.]]).reshape(3, )
     data_feed = RadialBasisFunctions(self.test_data,
                                      basis_function='linear',
                                      solution_method='bfgs')
     output_1 = data_feed.bfgs_parameter_optimization(x_vector, y)
     self.assertEqual(data_feed.solution_method, 'bfgs')
     np.testing.assert_array_equal(expected_value, np.round(output_1, 4))
예제 #2
0
 def test_bfgs_parameter_optimization_02(self):
     x = self.training_data[:, :-1]
     y = self.training_data[:, -1]
     x_vector = np.zeros((x.shape[0], 6))
     x_vector[:, 0] = x[:, 0]**2
     x_vector[:, 1] = x[:, 1]**2
     x_vector[:, 2] = x[:, 0]
     x_vector[:, 3] = x[:, 1]
     x_vector[:, 4] = x[:, 1] * x[:, 0]
     x_vector[:, 5] = 1
     expected_value = np.array([[1.], [1.], [2.], [2.], [0.],
                                [2.]]).reshape(6, )
     data_feed = RadialBasisFunctions(self.full_data,
                                      solution_method='bfgs')
     output_1 = data_feed.bfgs_parameter_optimization(x_vector, y)
     self.assertEqual(data_feed.solution_method, 'bfgs')
     np.testing.assert_array_equal(expected_value, np.round(output_1, 4))