class_docstr: Class to perform under-sampling based on NearMiss methods.
  
  Read more in the :ref:`User Guide <controlled_under_sampling>`.
  
  Parameters
  ----------
  {sampling_strategy}
  
  version : int, default=1
      Version of the NearMiss to use. Possible values are 1, 2 or 3.
  
  n_neighbors : int or estimator object, default=3
      If ``int``, size of the neighbourhood to consider to compute the
      average distance to the minority point samples.  If object, an
      estimator that inherits from
      :class:`~sklearn.neighbors.base.KNeighborsMixin` that will be used to
      find the k_neighbors.
      By default, it will be a 3-NN.
  
  n_neighbors_ver3 : int or estimator object, default=3
      If ``int``, NearMiss-3 algorithm start by a phase of re-sampling. This
      parameter correspond to the number of neighbours selected create the
      subset in which the selection will be performed.  If object, an
      estimator that inherits from
      :class:`~sklearn.neighbors.base.KNeighborsMixin` that will be used to
      find the k_neighbors.
      By default, it will be a 3-NN.
  
  {n_jobs}
  
  Attributes
  ----------
  sampling_strategy_ : dict
      Dictionary containing the information to sample the dataset. The keys
      corresponds 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 object created from `n_neighbors` parameter.
  
  sample_indices_ : ndarray of shape (n_new_samples,)
      Indices of the samples selected.
  
      .. versionadded:: 0.4
  
  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
  --------
  RandomUnderSampler : Random undersample the dataset.
  
  InstanceHardnessThreshold : Use of classifier to undersample a dataset.
  
  Notes
  -----
  The methods are based on [1]_.
  
  Supports multi-class resampling.
  
  References
  ----------
  .. [1] I. Mani, I. Zhang. "kNN approach to unbalanced data distributions:
     a case study involving information extraction," In Proceedings of
     workshop on learning from imbalanced datasets, 2003.
  
  Examples
  --------
  >>> from collections import Counter
  >>> from sklearn.datasets import make_classification
  >>> from imblearn.under_sampling import NearMiss
  >>> 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}})
  >>> nm = NearMiss()
  >>> X_res, y_res = nm.fit_resample(X, y)
  >>> print('Resampled dataset shape %s' % Counter(y_res))
  Resampled dataset shape Counter({{0: 100, 1: 100}})
class_docstr_tok: ["Class","to","perform","under-sampling","based","on","NearMiss","methods",".","Read","more","in","the",":","ref",":","`","User","Guide","<","controlled_under_sampling",">","`",".","Parameters","--","--","--","--","--","{","sampling_strategy","}","version",":","int",",","default=1","Version","of","the","NearMiss","to","use",".","Possible","values","are","1",",","2","or","3.","n_neighbors",":","int","or","estimator","object",",","default=3","If","``","int","``",",","size","of","the","neighbourhood","to","consider","to","compute","the","average","distance","to","the","minority","point","samples",".","If","object",",","an","estimator","that","inherits","from",":","class",":","`","~sklearn.neighbors.base.KNeighborsMixin","`","that","will","be","used","to","find","the","k_neighbors",".","By","default",",","it","will","be","a","3-NN",".","n_neighbors_ver3",":","int","or","estimator","object",",","default=3","If","``","int","``",",","NearMiss-3","algorithm","start","by","a","phase","of","re-sampling",".","This","parameter","correspond","to","the","number","of","neighbours","selected","create","the","subset","in","which","the","selection","will","be","performed",".","If","object",",","an","estimator","that","inherits","from",":","class",":","`","~sklearn.neighbors.base.KNeighborsMixin","`","that","will","be","used","to","find","the","k_neighbors",".","By","default",",","it","will","be","a","3-NN",".","{","n_jobs","}","Attributes","--","--","--","--","--","sampling_strategy_",":","dict","Dictionary","containing","the","information","to","sample","the","dataset",".","The","keys","corresponds","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","object","created","from","`","n_neighbors","`","parameter",".","sample_indices_",":","ndarray","of","shape","(","n_new_samples",",",")","Indices","of","the","samples","selected",".","..","versionadded",":",":","0.4","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","--","--","--","--","RandomUnderSampler",":","Random","undersample","the","dataset",".","InstanceHardnessThreshold",":","Use","of","classifier","to","undersample","a","dataset",".","Notes","--","--","-","The","methods","are","based","on","[","1","]","_",".","Supports","multi-class","resampling",".","References","--","--","--","--","--","..","[","1","]","I.","Mani",",","I.","Zhang",".","``","kNN","approach","to","unbalanced","data","distributions",":","a","case","study","involving","information","extraction",",","''","In","Proceedings","of","workshop","on","learning","from","imbalanced","datasets",",","2003",".","Examples","--","--","--","--",">",">",">","from","collections","import","Counter",">",">",">","from","sklearn.datasets","import","make_classification",">",">",">","from","imblearn.under_sampling","import","NearMiss",">",">",">","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","}","}",")",">",">",">","nm","=","NearMiss","(",")",">",">",">","X_res",",","y_res","=","nm.fit_resample","(","X",",","y",")",">",">",">","print","(","'Resampled","dataset","shape","%","s","'","%","Counter","(","y_res",")",")","Resampled","dataset","shape","Counter","(","{","{","0",":","100",",","1",":","100","}","}",")"]
code: def _more_tags(self):
      return {
          "sample_indices": True,
          "_xfail_checks": {
              "check_samplers_fit_resample": "Fails for NearMiss-3 with less samples than expected"
          },
      }
  
file_path: imbalanced-learn/imblearn/under_sampling/_prototype_selection/_nearmiss.py
imports: import numbers
  import warnings
  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
  from ..base import BaseUnderSampler
label_desc: Use image node_id 5 for calling the NearMiss obj's underlying member method code with example usage: obj._more_tags() and returns: dict