class_docstr: Base class for a Dynamic Classifier Selection (dcs) method.
  All dynamic classifier selection classes should inherit from this class.
  
  Warning: This class should not be used directly, use derived classes
  instead.
docstr: Select the most competent classifier for the classification of the
  query sample given the competence level estimates. Four selection
  schemes are available.
  
  Best : The base classifier with the highest competence level is
  selected. In cases where more than one base classifier achieves the
  same competence level, the one with the lowest index is selected. This
  method is the standard for the LCA, OLA, MLA techniques.
  
  Diff : Select the base classifier that is significantly better than the
  others in the pool (when the difference between its competence level
  and the competence level of the other base classifiers is higher than a
  predefined threshold). If no base classifier is significantly better,
  the base classifier is selected randomly among the member with
  equivalent competence level.
  
  Random : Selects a random base classifier among all base classifiers
  that achieved the same competence level.
  
  ALL : all base classifiers with the max competence level estimates are
  selected (note that in this case the
  DCS technique becomes a DES technique).
  
  Parameters
  ----------
  competences : array of shape (n_samples, n_classifiers)
      Competence level estimated for each base classifier and test
      example.
  
  Returns
  -------
  selected_classifiers : array of shape [n_samples]
      Indices of the selected base classifier for each sample. If the
      selection_method is set to 'all', a boolean matrix is returned,
      containing True for the selected base classifiers, otherwise false.
docstr_tok: ["Select","the","most","competent","classifier","for","the","classification","of","the","query","sample","given","the","competence","level","estimates",".","Four","selection","schemes","are","available",".","Best",":","The","base","classifier","with","the","highest","competence","level","is","selected",".","In","cases","where","more","than","one","base","classifier","achieves","the","same","competence","level",",","the","one","with","the","lowest","index","is","selected",".","This","method","is","the","standard","for","the","LCA",",","OLA",",","MLA","techniques",".","Diff",":","Select","the","base","classifier","that","is","significantly","better","than","the","others","in","the","pool","(","when","the","difference","between","its","competence","level","and","the","competence","level","of","the","other","base","classifiers","is","higher","than","a","predefined","threshold",")",".","If","no","base","classifier","is","significantly","better",",","the","base","classifier","is","selected","randomly","among","the","member","with","equivalent","competence","level",".","Random",":","Selects","a","random","base","classifier","among","all","base","classifiers","that","achieved","the","same","competence","level",".","ALL",":","all","base","classifiers","with","the","max","competence","level","estimates","are","selected","(","note","that","in","this","case","the","DCS","technique","becomes","a","DES","technique",")",".","Parameters","--","--","--","--","--","competences",":","array","of","shape","(","n_samples",",","n_classifiers",")","Competence","level","estimated","for","each","base","classifier","and","test","example",".","Returns","--","--","--","-","selected_classifiers",":","array","of","shape","[","n_samples","]","Indices","of","the","selected","base","classifier","for","each","sample",".","If","the","selection_method","is","set","to","'all","'",",","a","boolean","matrix","is","returned",",","containing","True","for","the","selected","base","classifiers",",","otherwise","false","."]
code: def select(self, competences):
      """Select the most competent classifier for the classification of the
      query sample given the competence level estimates. Four selection
      schemes are available.
  
      Best : The base classifier with the highest competence level is
      selected. In cases where more than one base classifier achieves the
      same competence level, the one with the lowest index is selected. This
      method is the standard for the LCA, OLA, MLA techniques.
  
      Diff : Select the base classifier that is significantly better than the
      others in the pool (when the difference between its competence level
      and the competence level of the other base classifiers is higher than a
      predefined threshold). If no base classifier is significantly better,
      the base classifier is selected randomly among the member with
      equivalent competence level.
  
      Random : Selects a random base classifier among all base classifiers
      that achieved the same competence level.
  
      ALL : all base classifiers with the max competence level estimates are
      selected (note that in this case the
      DCS technique becomes a DES technique).
  
      Parameters
      ----------
      competences : array of shape (n_samples, n_classifiers)
          Competence level estimated for each base classifier and test
          example.
  
      Returns
      -------
      selected_classifiers : array of shape [n_samples]
          Indices of the selected base classifier for each sample. If the
          selection_method is set to 'all', a boolean matrix is returned,
          containing True for the selected base classifiers, otherwise false.
  
      """
      if competences.ndim < 2:
          competences = competences.reshape(1, -1)
  
      selected_classifiers = []
      best_index = np.argmax(competences, axis=1)
  
      if self.selection_method == "best":
          # Select the classifier with highest competence level
          selected_classifiers = best_index
  
      elif self.selection_method == "diff":
          rng = check_random_state(copy(self.random_state))
          best_competence = competences[
              np.arange(competences.shape[0]), best_index
          ]
          # best_competence = np.max(competences)
          diff = best_competence.reshape(-1, 1) - competences
          # TODO: Improve this part of the code
          selected_classifiers = np.zeros(diff.shape[0], dtype=int)
          for row in range(diff.shape[0]):
              diff_list = list(diff[row, :])
              indices = [
                  idx
                  for idx, _ in enumerate(diff_list)
                  if diff_list[idx] < self.diff_thresh
              ]
  
              if len(indices) == 0:
                  indices = range(self.n_classifiers_)
  
              selected_classifiers[row] = rng.choice(indices)
  
      elif self.selection_method == "random":
          # TODO: Improve this part of the code
          rng = check_random_state(copy(self.random_state))
          selected_classifiers = np.zeros(
              competences.shape[0], dtype=int
          )
          best_competence = competences[
              np.arange(competences.shape[0]), best_index
          ]
          for row in range(competences.shape[0]):
              competence_list = list(competences[row, :])
  
              # Select a random classifier among all with same competence
              # level
              indices = [
                  idx
                  for idx, _ in enumerate(competence_list)
                  if competence_list[idx] == best_competence[row]
              ]
  
              selected_classifiers[row] = rng.choice(indices)
  
      elif self.selection_method == "all":
          # select all base classifiers with max competence estimates.
          max_value = np.max(competences, axis=1)
          selected_classifiers = competences == max_value.reshape(
              competences.shape[0], -1
          )
  
      return selected_classifiers
  
file_path: DESlib/deslib/dcs/base.py
imports: from abc import ABCMeta
  from copy import copy
  import numpy
  from sklearn.utils.validation import check_random_state
  from deslib.base import BaseDS
  from deslib.util.aggregation import majority_voting_rule
label_desc: Use image node_id 3 for calling the BaseDCS obj's underlying member method code with example usage: obj.select(competences) and returns: selected_classifiers