示例#1
0
    def test_admm_path_alphas(self):
        # check if input alphas are sorted
        X, y, X_test, y_test = build_dataset()

        alphas = [0.1, 0.3, 0.5, -0.1, -0.2]
        actual_alphas, _, _ = admm_path(X, y, alphas=alphas)
        assert_array_almost_equal(actual_alphas, [0.5, 0.3, 0.1, -0.1, -0.2])
示例#2
0
    def test_admm_path_coefs(self):
        # check if we can get correct coefs

        X = np.array([[-1.], [0.], [1.]])
        y = np.array([-1, 0, 1])  # just a straight line

        _, coefs_actual, _ = admm_path(X, y, alphas=[1e-8, 0.1, 0.5, 1], rho=1.0)
        assert_array_almost_equal(coefs_actual[0], [-1.31072000e-04, 2.53888000e-01, 8.49673483e-01, 9.99738771e-01],
                                  decimal=3)