@pytest.mark.parametrize('data', (make_classification(random_state=0), make_classification(n_classes=3, n_clusters_per_class=1, random_state=0)))
@pytest.mark.parametrize('scoring, validation_fraction, n_iter_no_change, tol', [('accuracy', 0.1, 5, 1e-07), ('accuracy', None, 5, 0.1), (None, 0.1, 5, 1e-07), (None, None, 5, 0.1), ('loss', 0.1, 5, 1e-07), ('loss', None, 5, 0.1), (None, None, None, None)])
def test_early_stopping_classification(data, scoring, validation_fraction, n_iter_no_change, tol):
    max_iter = 50
    (X, y) = data
    gb = HistGradientBoostingClassifier(verbose=1, min_samples_leaf=5, scoring=scoring, tol=tol, validation_fraction=validation_fraction, max_iter=max_iter, n_iter_no_change=n_iter_no_change, random_state=0)
    gb.fit(X, y)
    if (n_iter_no_change is not None):
        assert (n_iter_no_change <= gb.n_iter_ < max_iter)
    else:
        assert (gb.n_iter_ == max_iter)
@pytest.mark.parametrize('data', (make_classification(random_state=0), make_classification(n_classes=3, n_clusters_per_class=1, random_state=0)))
@pytest.mark.parametrize('scoring, validation_fraction, n_iter_no_change, tol', [('accuracy', 0.1, 5, 1e-07), ('accuracy', None, 5, 0.1), (None, 0.1, 5, 1e-07), (None, None, 5, 0.1), ('loss', 0.1, 5, 1e-07), ('loss', None, 5, 0.1), (None, None, None, None)])
def test_early_stopping_classification(data, scoring, validation_fraction, n_iter_no_change, tol):
    max_iter = 50
    (X, y) = data
    gb = HistGradientBoostingClassifier(verbose=1, min_samples_leaf=5, scoring=scoring, tol=tol, validation_fraction=validation_fraction, max_iter=max_iter, n_iter_no_change=n_iter_no_change, random_state=0)
    gb.fit(X, y)
    if (n_iter_no_change is not None):
        assert (n_iter_no_change <= gb.n_iter_ < max_iter)
    else:
        assert (gb.n_iter_ == max_iter)