class_docstr: An approach that approximates a submodular function as modular.
  
  This approach approximates the submodular function by using its modular 
  upper-bounds to do the selection. Essentially, a defining characteristic 
  of submodular functions is the *diminishing returns* property where the 
  gain of an example decreases with the number of selected examples. In 
  contrast, modular functions have constant gains for examples regardless 
  of the number of selected examples. Thus, approximating the submodular 
  function as a modular function can serve as an upper-bound to the gain 
  for each example during the selection process. This approximation makes 
  the function simple to optimize because one would simply calculate the 
  gain that each example yields before any examples are selected, sort the 
  examples by this gain, and select the top :math:`k` examples. While this 
  approach is fast, this approach is likely best paired with a traditional 
  optimization algorithm after the first few examples are selected.
  
  .. code::python
  
          from apricot import FeatureBasedSelection
  
          X = numpy.random.randint(10, size=(10000, 100))
  
          selector = FeatureBasedSelection(100, 'sqrt', optimizer='modular')
          selector.fit(X)
  
  Parameters
  ----------
  self.function : base.BaseSelection
          A submodular function that implements the `_calculate_gains` and
          `_select_next` methods. This is the function that will be
          optimized.
  
  epsilon : float, optional
          The inverse of the sampling probability of any particular point being 
          included in the subset, such that 1 - epsilon is the probability that
          a point is included. Default is 0.9.
  
  random_state : int or RandomState or None, optional
          The random seed to use for the random selection process.
  
  self.verbose : bool
          Whether to display a progress bar during the optimization process.
  
  
  Attributes
  ----------
  self.function : base.BaseSelection
          A submodular function that implements the `_calculate_gains` and
          `_select_next` methods. This is the function that will be
          optimized.
  
  self.verbose : bool
          Whether to display a progress bar during the optimization process.
  
  self.gains_ : numpy.ndarray or None
          The gain that each example would give the last time that it was
          evaluated.
class_docstr_tok: ["An","approach","that","approximates","a","submodular","function","as","modular",".","This","approach","approximates","the","submodular","function","by","using","its","modular","upper-bounds","to","do","the","selection",".","Essentially",",","a","defining","characteristic","of","submodular","functions","is","the","*","diminishing","returns","*","property","where","the","gain","of","an","example","decreases","with","the","number","of","selected","examples",".","In","contrast",",","modular","functions","have","constant","gains","for","examples","regardless","of","the","number","of","selected","examples",".","Thus",",","approximating","the","submodular","function","as","a","modular","function","can","serve","as","an","upper-bound","to","the","gain","for","each","example","during","the","selection","process",".","This","approximation","makes","the","function","simple","to","optimize","because","one","would","simply","calculate","the","gain","that","each","example","yields","before","any","examples","are","selected",",","sort","the","examples","by","this","gain",",","and","select","the","top",":","math",":","`","k","`","examples",".","While","this","approach","is","fast",",","this","approach","is","likely","best","paired","with","a","traditional","optimization","algorithm","after","the","first","few","examples","are","selected",".","..","code",":",":python","from","apricot","import","FeatureBasedSelection","X","=","numpy.random.randint","(","10",",","size=","(","10000",",","100",")",")","selector","=","FeatureBasedSelection","(","100",",","'sqrt","'",",","optimizer='modular","'",")","selector.fit","(","X",")","Parameters","--","--","--","--","--","self.function",":","base.BaseSelection","A","submodular","function","that","implements","the","`","_calculate_gains","`","and","`","_select_next","`","methods",".","This","is","the","function","that","will","be","optimized",".","epsilon",":","float",",","optional","The","inverse","of","the","sampling","probability","of","any","particular","point","being","included","in","the","subset",",","such","that","1","-","epsilon","is","the","probability","that","a","point","is","included",".","Default","is","0.9.","random_state",":","int","or","RandomState","or","None",",","optional","The","random","seed","to","use","for","the","random","selection","process",".","self.verbose",":","bool","Whether","to","display","a","progress","bar","during","the","optimization","process",".","Attributes","--","--","--","--","--","self.function",":","base.BaseSelection","A","submodular","function","that","implements","the","`","_calculate_gains","`","and","`","_select_next","`","methods",".","This","is","the","function","that","will","be","optimized",".","self.verbose",":","bool","Whether","to","display","a","progress","bar","during","the","optimization","process",".","self.gains_",":","numpy.ndarray","or","None","The","gain","that","each","example","would","give","the","last","time","that","it","was","evaluated","."]
code: def __init__(
      self, function=None, random_state=None, n_jobs=None, verbose=False
  ):
      super(ModularGreedy, self).__init__(
          function=function,
          random_state=random_state,
          n_jobs=n_jobs,
          verbose=verbose,
      )
  
imports: import os
  import copy
  import numpy
  import scipy
  from tqdm import tqdm
  from .utils import PriorityQueue
  from .utils import check_random_state
  from .utils import _calculate_pairwise_distances
label_desc: Use image node_id 1 to create a new ModularGreedy object from inherited base classes: BaseOptimizer with example: obj = ModularGreedy(function, random_state, n_jobs, verbose)