def test_ncr_threshold_cleaning(data):
    """Test the effect of the `threshold_cleaning` parameter."""
    X, y = data
    # with a large `threshold_cleaning`, the algorithm is equivalent to ENN
    enn = EditedNearestNeighbours()
    ncr = NeighbourhoodCleaningRule(
        edited_nearest_neighbours=enn, n_neighbors=10, threshold_cleaning=10
    )

    enn.fit_resample(X, y)
    ncr.fit_resample(X, y)

    assert_array_equal(np.sort(enn.sample_indices_), np.sort(ncr.sample_indices_))
    assert ncr.classes_to_clean_ == []

    # set a threshold that we should consider only the class #2
    counter = Counter(y)
    threshold = counter[1] / counter[0]
    ncr.set_params(threshold_cleaning=threshold)
    ncr.fit_resample(X, y)

    assert set(ncr.classes_to_clean_) == {2}

    # making the threshold slightly smaller to take into account class #1
    ncr.set_params(threshold_cleaning=threshold - np.finfo(np.float32).eps)
    ncr.fit_resample(X, y)

    assert set(ncr.classes_to_clean_) == {1, 2}
Test the effect of the `threshold_cleaning` parameter.
imblearn/under_sampling/_prototype_selection/tests/test_neighbourhood_cleaning_rule.py