def test_poisson():
    """Test basic functionality of UoI_Lasso and that it finds right model"""
    n_features = 20
    n_inf = 10
    X, y, w, b = make_poisson_regression(n_samples=200,
                                         n_features=n_features,
                                         n_informative=n_inf,
                                         random_state=10)
    poisson = UoI_Poisson(comm=MPI.COMM_WORLD)
    poisson.fit(X, y)
    assert (np.sign(abs(w)) == np.sign(abs(poisson.coef_))).mean() >= .6
Beispiel #2
0
def test_UoI_Poisson_all_zeros():
    """Test that UoI Poisson correctly fits the data when the response variable
    is all zeros."""
    n_features = 5
    n_samples = 100

    X = np.random.normal(size=(n_samples, n_features))
    y = np.zeros(n_samples)

    poisson = UoI_Poisson()
    poisson.fit(X, y)

    assert_equal(poisson.intercept_, -np.inf)
    assert_equal(poisson.coef_, np.zeros(n_features))
Beispiel #3
0
def test_UoI_Poisson():
    """Tests the UoI Poisson fitter with lbfgs solver."""
    n_features = 3
    n_samples = 5000

    # create data
    X, y, beta, _ = make_poisson_regression(n_samples=n_samples,
                                            n_features=n_features,
                                            n_informative=n_features,
                                            beta=np.array([0., 1.0, 1.5]),
                                            random_state=2332)

    # lbfgs
    poisson = UoI_Poisson(n_lambdas=48, n_boots_sel=30, n_boots_est=30,
                          alphas=np.array([1.0]), warm_start=False)
    poisson.fit(X, y)

    assert_allclose(poisson.coef_, beta, atol=0.5)