code: 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}
  
file_path: imbalanced-learn/imblearn/under_sampling/_prototype_selection/tests/test_neighbourhood_cleaning_rule.py
imports: from collections import Counter
  import numpy
  import pytest
  from sklearn.datasets import make_classification
  from sklearn.utils._testing import assert_array_equal
  from imblearn.under_sampling import EditedNearestNeighbours, NeighbourhoodCleaningRule
label_desc: Use image node_id 2 for calling a global function with example usage: test_ncr_threshold_cleaning(data) without return types