class_docstr: A selector based off a custom, user-defined feature-based function.
  
  This selector wraps a custom function that is passed in by the user. This
  function should take in a matrix containing a subset of the ground set and
  output the standard measure of quality of the subset. Each row in the matrix
  should be an example and each column should be a feature value for the 
  example (like a standard data matrix for machine learning).
  
  .. warning::
          If the function that the user wants to optimize is graph-based,
          i.e., that it determines the quality of a subset using similarities
          with other examples instead of the feature values directly, 
          e.g. facility location, CustomGraphSelection should be used instead. 
  
  .. note:: 
          Although apricot is built for submodular functions, there is no explicit
          restriction that the function passed in be submodular. Sometimes,
          supermodular functions can be reasonably maximized using the same
          greedy approaches used on submodular functions.
  
  
  Parameters
  ----------
  n_samples : int
          The number of samples to return.
  
  func : function
          The feature-based set function to that this selector should wrap.
  
  initial_subset : list, numpy.ndarray or None
          If provided, this should be a list of indices into the data matrix
          to use as the initial subset, or a group of examples that may not be
          in the provided data should beused as the initial subset. If indices, 
          the provided array should be one-dimensional. If a group of examples,
          the data should be 2 dimensional.
  
  optimizer : string or optimizers.BaseOptimizer, optional
          The optimization approach to use for the selection. Default is
          'two-stage', which makes selections using the naive greedy algorithm
          initially and then switches to the lazy greedy algorithm. Must be
          one of
  
                  'random' : randomly select elements (dummy optimizer)
                  'modular' : approximate the function using its modular upper bound
                  'naive' : the naive greedy algorithm
                  'lazy' : the lazy (or accelerated) greedy algorithm
                  'approximate-lazy' : the approximate lazy greedy algorithm
                  'two-stage' : starts with naive and switches to lazy
                  'stochastic' : the stochastic greedy algorithm
                  'sample' : randomly take a subset and perform selection on that
                  'greedi' : the GreeDi distributed algorithm
                  'bidirectional' : the bidirectional greedy algorithm
  
          Default is 'two-stage'.
  
  optimizer_kwds : dict, optional
          Arguments to pass into the optimizer object upon initialization.
          Default is {}.
  
  function_kwds : dict, optional
          Arguments to pass into the function object for each call.
          Default is {}.
  
  n_jobs : int, optional
          The number of cores to use for processing. This value is multiplied
          by 2 when used to set the number of threads. If set to -1, use all
          cores and threads. Default is -1.
  
  random_state : int or RandomState or None, optional
          The random seed to use for the random selection process. Only used
          for stochastic greedy.
  
  verbose : bool
          Whether to print output during the selection process.
  
  Attributes
  ----------
  n_samples : int
          The number of samples to select.
  
  ranking : numpy.array int
          The selected samples in the order of their gain with the first number in
          the ranking corresponding to the index of the first sample that was
          selected by the greedy procedure.
  
  gains : numpy.array float
          The gain of each sample in the returned set when it was added to the
          growing subset. The first number corresponds to the gain of the first
          added sample, the second corresponds to the gain of the second added
          sample, and so forth.
class_docstr_tok: ["A","selector","based","off","a","custom",",","user-defined","feature-based","function",".","This","selector","wraps","a","custom","function","that","is","passed","in","by","the","user",".","This","function","should","take","in","a","matrix","containing","a","subset","of","the","ground","set","and","output","the","standard","measure","of","quality","of","the","subset",".","Each","row","in","the","matrix","should","be","an","example","and","each","column","should","be","a","feature","value","for","the","example","(","like","a","standard","data","matrix","for","machine","learning",")",".","..","warning",":",":","If","the","function","that","the","user","wants","to","optimize","is","graph-based",",","i.e.",",","that","it","determines","the","quality","of","a","subset","using","similarities","with","other","examples","instead","of","the","feature","values","directly",",","e.g",".","facility","location",",","CustomGraphSelection","should","be","used","instead",".","..","note",":",":","Although","apricot","is","built","for","submodular","functions",",","there","is","no","explicit","restriction","that","the","function","passed","in","be","submodular",".","Sometimes",",","supermodular","functions","can","be","reasonably","maximized","using","the","same","greedy","approaches","used","on","submodular","functions",".","Parameters","--","--","--","--","--","n_samples",":","int","The","number","of","samples","to","return",".","func",":","function","The","feature-based","set","function","to","that","this","selector","should","wrap",".","initial_subset",":","list",",","numpy.ndarray","or","None","If","provided",",","this","should","be","a","list","of","indices","into","the","data","matrix","to","use","as","the","initial","subset",",","or","a","group","of","examples","that","may","not","be","in","the","provided","data","should","beused","as","the","initial","subset",".","If","indices",",","the","provided","array","should","be","one-dimensional",".","If","a","group","of","examples",",","the","data","should","be","2","dimensional",".","optimizer",":","string","or","optimizers.BaseOptimizer",",","optional","The","optimization","approach","to","use","for","the","selection",".","Default","is","'two-stage","'",",","which","makes","selections","using","the","naive","greedy","algorithm","initially","and","then","switches","to","the","lazy","greedy","algorithm",".","Must","be","one","of","'random","'",":","randomly","select","elements","(","dummy","optimizer",")","'modular","'",":","approximate","the","function","using","its","modular","upper","bound","'naive","'",":","the","naive","greedy","algorithm","'lazy","'",":","the","lazy","(","or","accelerated",")","greedy","algorithm","'approximate-lazy","'",":","the","approximate","lazy","greedy","algorithm","'two-stage","'",":","starts","with","naive","and","switches","to","lazy","'stochastic","'",":","the","stochastic","greedy","algorithm","'sample","'",":","randomly","take","a","subset","and","perform","selection","on","that","'greedi","'",":","the","GreeDi","distributed","algorithm","'bidirectional","'",":","the","bidirectional","greedy","algorithm","Default","is","'two-stage","'",".","optimizer_kwds",":","dict",",","optional","Arguments","to","pass","into","the","optimizer","object","upon","initialization",".","Default","is","{","}",".","function_kwds",":","dict",",","optional","Arguments","to","pass","into","the","function","object","for","each","call",".","Default","is","{","}",".","n_jobs",":","int",",","optional","The","number","of","cores","to","use","for","processing",".","This","value","is","multiplied","by","2","when","used","to","set","the","number","of","threads",".","If","set","to","-1",",","use","all","cores","and","threads",".","Default","is","-1.","random_state",":","int","or","RandomState","or","None",",","optional","The","random","seed","to","use","for","the","random","selection","process",".","Only","used","for","stochastic","greedy",".","verbose",":","bool","Whether","to","print","output","during","the","selection","process",".","Attributes","--","--","--","--","--","n_samples",":","int","The","number","of","samples","to","select",".","ranking",":","numpy.array","int","The","selected","samples","in","the","order","of","their","gain","with","the","first","number","in","the","ranking","corresponding","to","the","index","of","the","first","sample","that","was","selected","by","the","greedy","procedure",".","gains",":","numpy.array","float","The","gain","of","each","sample","in","the","returned","set","when","it","was","added","to","the","growing","subset",".","The","first","number","corresponds","to","the","gain","of","the","first","added","sample",",","the","second","corresponds","to","the","gain","of","the","second","added","sample",",","and","so","forth","."]
docstr: Run submodular optimization to select the examples.
  
  This method is a wrapper for the full submodular optimization process.
  It takes in some data set (and optionally labels that are ignored
  during this process) and selects `n_samples` from it in the greedy
  manner specified by the optimizer.
  
  This method will return the selector object itself, not the transformed
  data set. The `transform` method will then transform a data set to the
  selected points, or alternatively one can use the ranking stored in
  the `self.ranking` attribute. The `fit_transform` method will perform
  both optimization and selection and return the selected items.
  
  Parameters
  ----------
  X : list or numpy.ndarray, shape=(n, d)
          The data set to transform. Must be numeric.
  
  y : list or numpy.ndarray or None, shape=(n,), optional
          The labels to transform. If passed in this function will return
          both the data and th corresponding labels for the rows that have
          been selected.
  
  sample_weight : list or numpy.ndarray or None, shape=(n,), optional
          The weight of each example. Currently ignored in apricot but
          included to maintain compatibility with sklearn pipelines. 
  
  sample_cost : list or numpy.ndarray or None, shape=(n,), optional
          The cost of each item. If set, indicates that optimization should
          be performed with respect to a knapsack constraint.
  
  Returns
  -------
  self : CustomSelection
          The fit step returns this selector object.
docstr_tok: ["Run","submodular","optimization","to","select","the","examples",".","This","method","is","a","wrapper","for","the","full","submodular","optimization","process",".","It","takes","in","some","data","set","(","and","optionally","labels","that","are","ignored","during","this","process",")","and","selects","`","n_samples","`","from","it","in","the","greedy","manner","specified","by","the","optimizer",".","This","method","will","return","the","selector","object","itself",",","not","the","transformed","data","set",".","The","`","transform","`","method","will","then","transform","a","data","set","to","the","selected","points",",","or","alternatively","one","can","use","the","ranking","stored","in","the","`","self.ranking","`","attribute",".","The","`","fit_transform","`","method","will","perform","both","optimization","and","selection","and","return","the","selected","items",".","Parameters","--","--","--","--","--","X",":","list","or","numpy.ndarray",",","shape=","(","n",",","d",")","The","data","set","to","transform",".","Must","be","numeric",".","y",":","list","or","numpy.ndarray","or","None",",","shape=","(","n",",",")",",","optional","The","labels","to","transform",".","If","passed","in","this","function","will","return","both","the","data","and","th","corresponding","labels","for","the","rows","that","have","been","selected",".","sample_weight",":","list","or","numpy.ndarray","or","None",",","shape=","(","n",",",")",",","optional","The","weight","of","each","example",".","Currently","ignored","in","apricot","but","included","to","maintain","compatibility","with","sklearn","pipelines",".","sample_cost",":","list","or","numpy.ndarray","or","None",",","shape=","(","n",",",")",",","optional","The","cost","of","each","item",".","If","set",",","indicates","that","optimization","should","be","performed","with","respect","to","a","knapsack","constraint",".","Returns","--","--","--","-","self",":","CustomSelection","The","fit","step","returns","this","selector","object","."]
code: def fit(self, X, y=None, sample_weight=None, sample_cost=None):
      """Run submodular optimization to select the examples.
  
      This method is a wrapper for the full submodular optimization process.
      It takes in some data set (and optionally labels that are ignored
      during this process) and selects `n_samples` from it in the greedy
      manner specified by the optimizer.
  
      This method will return the selector object itself, not the transformed
      data set. The `transform` method will then transform a data set to the
      selected points, or alternatively one can use the ranking stored in
      the `self.ranking` attribute. The `fit_transform` method will perform
      both optimization and selection and return the selected items.
  
      Parameters
      ----------
      X : list or numpy.ndarray, shape=(n, d)
              The data set to transform. Must be numeric.
  
      y : list or numpy.ndarray or None, shape=(n,), optional
              The labels to transform. If passed in this function will return
              both the data and th corresponding labels for the rows that have
              been selected.
  
      sample_weight : list or numpy.ndarray or None, shape=(n,), optional
              The weight of each example. Currently ignored in apricot but
              included to maintain compatibility with sklearn pipelines.
  
      sample_cost : list or numpy.ndarray or None, shape=(n,), optional
              The cost of each item. If set, indicates that optimization should
              be performed with respect to a knapsack constraint.
  
      Returns
      -------
      self : CustomSelection
              The fit step returns this selector object.
      """
  
      return super(CustomSelection, self).fit(
          X, y=y, sample_weight=sample_weight, sample_cost=sample_cost
      )
  
file_path: apricot/apricot/functions/custom.py
imports: import numpy
  from .base import BaseSelection
  from .base import BaseGraphSelection
label_desc: Use image node_id 2 for calling the CustomSelection obj's underlying member method code with example usage: obj.fit(X, y, sample_weight, sample_cost) and returns: super