예제 #1
0
def test_lbfgs_regression_maxfun(X, y):
    # Test lbfgs parameter max_fun.
    # It should independently limit the number of iterations for lbfgs.
    max_fun = 10
    # regression tests
    for activation in ACTIVATION_TYPES:
        mlp = MLPRegressor(solver='lbfgs', hidden_layer_sizes=50, tol=0.0,
                           max_iter=150, max_fun=max_fun, shuffle=True,
                           random_state=1, activation=activation)
        with pytest.warns(ConvergenceWarning):
            mlp.fit(X, y)
            assert max_fun >= mlp.n_iter_

    mlp.max_fun = -1
    with pytest.raises(ValueError):
        mlp.fit(X, y)