class_docstr: Undersample based on the repeated edited nearest neighbour method.
  
  This method repeats the :class:`EditedNearestNeighbours` algorithm several times.
  The repetitions will stop when i) the maximum number of iterations is reached,
  or ii) no more observations are being removed, or iii) one of the majority classes
  becomes a minority class or iv) one of the majority classes disappears
  during undersampling.
  
  Read more in the :ref:`User Guide <edited_nearest_neighbors>`.
  
  Parameters
  ----------
  {sampling_strategy}
  
  n_neighbors : int or object, default=3
      If ``int``, size of the neighbourhood to consider for the undersampling, i.e.,
      if `n_neighbors=3`, a sample will be removed when any or most of its 3 closest
      neighbours are from a different class. If object, an estimator that inherits
      from :class:`~sklearn.neighbors.base.KNeighborsMixin` that will be used to
      find the nearest-neighbors. Note that if you want to examine the 3 closest
      neighbours of a sample for the undersampling, you need to pass a 4-KNN.
  
  max_iter : int, default=100
      Maximum number of iterations of the edited nearest neighbours.
  
  kind_sel : {{'all', 'mode'}}, default='all'
      Strategy to use to exclude samples.
  
      - If ``'all'``, all neighbours should be of the same class of the examined
        sample for it not be excluded.
      - If ``'mode'``, most neighbours should be of the same class of the examined
        sample for it not be excluded.
  
      The strategy `"all"` will be less conservative than `'mode'`. Thus,
      more samples will be removed when `kind_sel="all"`, generally.
  
  {n_jobs}
  
  Attributes
  ----------
  sampling_strategy_ : dict
      Dictionary containing the information to sample the dataset. The keys
      correspond to the class labels from which to sample and the values
      are the number of samples to sample.
  
  nn_ : estimator object
      Validated K-nearest Neighbours estimator linked to the parameter `n_neighbors`.
  
  enn_ : sampler object
      The validated :class:`~imblearn.under_sampling.EditedNearestNeighbours`
      instance.
  
  sample_indices_ : ndarray of shape (n_new_samples,)
      Indices of the samples selected.
  
      .. versionadded:: 0.4
  
  n_iter_ : int
      Number of iterations run.
  
      .. versionadded:: 0.6
  
  n_features_in_ : int
      Number of features in the input dataset.
  
      .. versionadded:: 0.9
  
  feature_names_in_ : ndarray of shape (`n_features_in_`,)
      Names of features seen during `fit`. Defined only when `X` has feature
      names that are all strings.
  
      .. versionadded:: 0.10
  
  See Also
  --------
  CondensedNearestNeighbour : Undersample by condensing samples.
  
  EditedNearestNeighbours : Undersample by editing samples.
  
  AllKNN : Undersample using ENN with varying neighbours.
  
  Notes
  -----
  The method is based on [1]_. A one-vs.-rest scheme is used when
  sampling a class as proposed in [1]_.
  
  Supports multi-class resampling.
  
  References
  ----------
  .. [1] I. Tomek, "An Experiment with the Edited Nearest-Neighbor
     Rule," IEEE Transactions on Systems, Man, and Cybernetics, vol. 6(6),
     pp. 448-452, June 1976.
  
  Examples
  --------
  >>> from collections import Counter
  >>> from sklearn.datasets import make_classification
  >>> from imblearn.under_sampling import RepeatedEditedNearestNeighbours
  >>> X, y = make_classification(n_classes=2, class_sep=2,
  ... weights=[0.1, 0.9], n_informative=3, n_redundant=1, flip_y=0,
  ... n_features=20, n_clusters_per_class=1, n_samples=1000, random_state=10)
  >>> print('Original dataset shape %s' % Counter(y))
  Original dataset shape Counter({{1: 900, 0: 100}})
  >>> renn = RepeatedEditedNearestNeighbours()
  >>> X_res, y_res = renn.fit_resample(X, y)
  >>> print('Resampled dataset shape %s' % Counter(y_res))
  Resampled dataset shape Counter({{1: 887, 0: 100}})
class_docstr_tok: ["Undersample","based","on","the","repeated","edited","nearest","neighbour","method",".","This","method","repeats","the",":","class",":","`","EditedNearestNeighbours","`","algorithm","several","times",".","The","repetitions","will","stop","when","i",")","the","maximum","number","of","iterations","is","reached",",","or","ii",")","no","more","observations","are","being","removed",",","or","iii",")","one","of","the","majority","classes","becomes","a","minority","class","or","iv",")","one","of","the","majority","classes","disappears","during","undersampling",".","Read","more","in","the",":","ref",":","`","User","Guide","<","edited_nearest_neighbors",">","`",".","Parameters","--","--","--","--","--","{","sampling_strategy","}","n_neighbors",":","int","or","object",",","default=3","If","``","int","``",",","size","of","the","neighbourhood","to","consider","for","the","undersampling",",","i.e.",",","if","`","n_neighbors=3","`",",","a","sample","will","be","removed","when","any","or","most","of","its","3","closest","neighbours","are","from","a","different","class",".","If","object",",","an","estimator","that","inherits","from",":","class",":","`","~sklearn.neighbors.base.KNeighborsMixin","`","that","will","be","used","to","find","the","nearest-neighbors",".","Note","that","if","you","want","to","examine","the","3","closest","neighbours","of","a","sample","for","the","undersampling",",","you","need","to","pass","a","4-KNN",".","max_iter",":","int",",","default=100","Maximum","number","of","iterations","of","the","edited","nearest","neighbours",".","kind_sel",":","{","{","'all","'",",","'mode","'","}","}",",","default='all'","Strategy","to","use","to","exclude","samples",".","-","If","``","'all","'","``",",","all","neighbours","should","be","of","the","same","class","of","the","examined","sample","for","it","not","be","excluded",".","-","If","``","'mode","'","``",",","most","neighbours","should","be","of","the","same","class","of","the","examined","sample","for","it","not","be","excluded",".","The","strategy","`","``","all","''","`","will","be","less","conservative","than","`","'mode","'","`",".","Thus",",","more","samples","will","be","removed","when","`","kind_sel=","''","all","''","`",",","generally",".","{","n_jobs","}","Attributes","--","--","--","--","--","sampling_strategy_",":","dict","Dictionary","containing","the","information","to","sample","the","dataset",".","The","keys","correspond","to","the","class","labels","from","which","to","sample","and","the","values","are","the","number","of","samples","to","sample",".","nn_",":","estimator","object","Validated","K-nearest","Neighbours","estimator","linked","to","the","parameter","`","n_neighbors","`",".","enn_",":","sampler","object","The","validated",":","class",":","`","~imblearn.under_sampling.EditedNearestNeighbours","`","instance",".","sample_indices_",":","ndarray","of","shape","(","n_new_samples",",",")","Indices","of","the","samples","selected",".","..","versionadded",":",":","0.4","n_iter_",":","int","Number","of","iterations","run",".","..","versionadded",":",":","0.6","n_features_in_",":","int","Number","of","features","in","the","input","dataset",".","..","versionadded",":",":","0.9","feature_names_in_",":","ndarray","of","shape","(","`","n_features_in_","`",",",")","Names","of","features","seen","during","`","fit","`",".","Defined","only","when","`","X","`","has","feature","names","that","are","all","strings",".","..","versionadded",":",":","0.10","See","Also","--","--","--","--","CondensedNearestNeighbour",":","Undersample","by","condensing","samples",".","EditedNearestNeighbours",":","Undersample","by","editing","samples",".","AllKNN",":","Undersample","using","ENN","with","varying","neighbours",".","Notes","--","--","-","The","method","is","based","on","[","1","]","_",".","A","one-vs.-rest","scheme","is","used","when","sampling","a","class","as","proposed","in","[","1","]","_",".","Supports","multi-class","resampling",".","References","--","--","--","--","--","..","[","1","]","I.","Tomek",",","``","An","Experiment","with","the","Edited","Nearest-Neighbor","Rule",",","''","IEEE","Transactions","on","Systems",",","Man",",","and","Cybernetics",",","vol",".","6","(","6",")",",","pp",".","448-452",",","June","1976",".","Examples","--","--","--","--",">",">",">","from","collections","import","Counter",">",">",">","from","sklearn.datasets","import","make_classification",">",">",">","from","imblearn.under_sampling","import","RepeatedEditedNearestNeighbours",">",">",">","X",",","y","=","make_classification","(","n_classes=2",",","class_sep=2",",","...","weights=","[","0.1",",","0.9","]",",","n_informative=3",",","n_redundant=1",",","flip_y=0",",","...","n_features=20",",","n_clusters_per_class=1",",","n_samples=1000",",","random_state=10",")",">",">",">","print","(","'Original","dataset","shape","%","s","'","%","Counter","(","y",")",")","Original","dataset","shape","Counter","(","{","{","1",":","900",",","0",":","100","}","}",")",">",">",">","renn","=","RepeatedEditedNearestNeighbours","(",")",">",">",">","X_res",",","y_res","=","renn.fit_resample","(","X",",","y",")",">",">",">","print","(","'Resampled","dataset","shape","%","s","'","%","Counter","(","y_res",")",")","Resampled","dataset","shape","Counter","(","{","{","1",":","887",",","0",":","100","}","}",")"]
docstr: Private function to create the NN estimator
docstr_tok: ["Private","function","to","create","the","NN","estimator"]
code: def _validate_estimator(self):
      """Private function to create the NN estimator"""
      self.nn_ = check_neighbors_object(
          "n_neighbors", self.n_neighbors, additional_neighbor=1
      )
  
      self.enn_ = EditedNearestNeighbours(
          sampling_strategy=self.sampling_strategy,
          n_neighbors=self.nn_,
          kind_sel=self.kind_sel,
          n_jobs=self.n_jobs,
      )
  
imports: import numbers
  from collections import Counter
  import numpy
  from sklearn.utils import _safe_indexing
  from ...utils import Substitution, check_neighbors_object
  from ...utils._docstring import _n_jobs_docstring
  from ...utils._param_validation import HasMethods, Interval, StrOptions
  from ...utils.fixes import _mode
  from ..base import BaseCleaningSampler
label_desc: Use image node_id 2 for calling the RepeatedEditedNearestNeighbours obj's underlying member method code with example usage: obj._validate_estimator() without return types