class_docstr: Base Index class.
  
  Specification of indexer-wide methods and attributes that we can always
  expect to find in any indexer. Helps to provide a uniform interface
  during parallel estimation.
class_docstr_tok: ["Base","Index","class",".","Specification","of","indexer-wide","methods","and","attributes","that","we","can","always","expect","to","find","in","any","indexer",".","Helps","to","provide","a","uniform","interface","during","parallel","estimation","."]
docstr: Front-end generator method.
  
  Generator for training and test set indices based on the
  generator specification in ``_gen_indicies``.
  
  Parameters
  ----------
  X : array-like, optional
      If instance has not been fitted, the training set ``X`` must be
      passed to the ``generate`` method, which will call ``fit`` before
      proceeding. If already fitted, ``X`` can be omitted.
  
  as_array : bool (default = False)
      whether to return train and test indices as a pair of tuple(s)
      or numpy arrays. If the returned tuples are singular they can be
      used on an array X with standard slicing syntax
      (``X[start:stop]``), but if a list of tuples is returned
      slicing ``X`` properly requires first building a list or array
      of index numbers from the list of tuples. This can be achieved
      either by setting ``as_array`` to ``True``, or running ::
  
          for train_tup, test_tup in indexer.generate():
              train_idx = \
                  np.hstack([np.arange(t0, t1) for t0, t1 in train_tup])
  
      when slicing is required.
docstr_tok: ["Front-end","generator","method",".","Generator","for","training","and","test","set","indices","based","on","the","generator","specification","in","``","_gen_indicies","``",".","Parameters","--","--","--","--","--","X",":","array-like",",","optional","If","instance","has","not","been","fitted",",","the","training","set","``","X","``","must","be","passed","to","the","``","generate","``","method",",","which","will","call","``","fit","``","before","proceeding",".","If","already","fitted",",","``","X","``","can","be","omitted",".","as_array",":","bool","(","default","=","False",")","whether","to","return","train","and","test","indices","as","a","pair","of","tuple","(","s",")","or","numpy","arrays",".","If","the","returned","tuples","are","singular","they","can","be","used","on","an","array","X","with","standard","slicing","syntax","(","``","X","[","start",":","stop","]","``",")",",","but","if","a","list","of","tuples","is","returned","slicing","``","X","``","properly","requires","first","building","a","list","or","array","of","index","numbers","from","the","list","of","tuples",".","This","can","be","achieved","either","by","setting","``","as_array","``","to","``","True","``",",","or","running",":",":","for","train_tup",",","test_tup","in","indexer.generate","(",")",":","train_idx","=","\\","np.hstack","(","[","np.arange","(","t0",",","t1",")","for","t0",",","t1","in","train_tup","]",")","when","slicing","is","required","."]
code: def generate(self, X=None, as_array=False):
      r"""Front-end generator method.
  
          Generator for training and test set indices based on the
          generator specification in ``_gen_indicies``.
  
          Parameters
          ----------
          X : array-like, optional
              If instance has not been fitted, the training set ``X`` must be
              passed to the ``generate`` method, which will call ``fit`` before
              proceeding. If already fitted, ``X`` can be omitted.
  
          as_array : bool (default = False)
              whether to return train and test indices as a pair of tuple(s)
              or numpy arrays. If the returned tuples are singular they can be
              used on an array X with standard slicing syntax
              (``X[start:stop]``), but if a list of tuples is returned
              slicing ``X`` properly requires first building a list or array
              of index numbers from the list of tuples. This can be achieved
              either by setting ``as_array`` to ``True``, or running ::
  
                  for train_tup, test_tup in indexer.generate():
                      train_idx = \
                          np.hstack([np.arange(t0, t1) for t0, t1 in train_tup])
  
              when slicing is required.
          """
      # Check that the instance have some array information to work with
      if not self.__fitted__:
          if X is None:
              raise AttributeError(
                  "No array provided to indexer. Either "
                  "pass an array to the 'generate' method, "
                  "or call the 'fit' method first or "
                  "initiate the instance with an array X "
                  "as argument."
              )
          # Need to call fit to continue
          self.fit(X)
  
      for tri, tei in self._gen_indices():
          if as_array:
              tri = self._build_range(tri)
              tei = self._build_range(tei)
  
          yield tri, tei
  
imports: from __future__ import division
  from abc import abstractmethod
  import numpy
  from ..externals.sklearn.base import BaseEstimator
label_desc: Use image node_id 5 for calling the BaseIndex obj's underlying member method code with example usage: obj.generate(X, as_array) without return types