def test_gradientdescent_regparam(): x, y = data.continuous_data_complicated() X = np.column_stack((np.ones(np.shape(x)[0]), x)) weights = descentmethods.gradientdescent(X, y, gradient(), reg_param=0.01) target = [0.47, 0.84] np.testing.assert_array_almost_equal(weights, target, 1)
def test_gradientdescent_initialweights(): x, y = data.continuous_data_complicated() X = np.column_stack((np.ones(np.shape(x)[0]), x)) weights = descentmethods.gradientdescent(X, y, gradient(), initial_weights=np.array([0.2, 0.2])) target = [0.47, 0.84] np.testing.assert_array_almost_equal(weights, target, 1)
def test_gradientdescent_initialweights(): x, y = data.continuous_data_complicated() X = np.column_stack((np.ones(np.shape(x)[0]), x)) weights = descentmethods.gradientdescent(X, y, gradient(), initial_weights=np.array( [0.2, 0.2])) target = [0.47, 0.84] np.testing.assert_array_almost_equal(weights, target, 1)
def test_gradientdescent_lowiterations(): x, y = data.continuous_data_complicated() X = np.column_stack((np.ones(np.shape(x)[0]), x)) weights = descentmethods.gradientdescent(X, y, gradient(), iterations=2) target = [0.1, 0.4] np.testing.assert_array_almost_equal(weights, target, 1)