class_docstr: The Ensemble class can be used to create ensembles of stellargraph's graph neural network algorithms including
  GCN, GraphSAGE, GAT, and HinSAGE. Ensembles can be used for training classification and regression problems for
  node attribute inference and link prediction.
  
  The Ensemble class can be used to create Naive ensembles.
  
  Naive ensembles add model diversity by random initialisation of the models' weights (before training) to
  different values. Each model in the ensemble is trained on the same training set of examples.
  
  .. seealso::
  
     Example using ensembles: `node classification <https://stellargraph.readthedocs.io/en/stable/demos/ensembles/ensemble-node-classification-example.html>`__.
  
     Related functionality: :class:`.BaggingEnsemble` for bootstrap sampling while training, in addition to random initialisation.
class_docstr_tok: ["The","Ensemble","class","can","be","used","to","create","ensembles","of","stellargraph","'s","graph","neural","network","algorithms","including","GCN",",","GraphSAGE",",","GAT",",","and","HinSAGE",".","Ensembles","can","be","used","for","training","classification","and","regression","problems","for","node","attribute","inference","and","link","prediction",".","The","Ensemble","class","can","be","used","to","create","Naive","ensembles",".","Naive","ensembles","add","model","diversity","by","random","initialisation","of","the","models","'","weights","(","before","training",")","to","different","values",".","Each","model","in","the","ensemble","is","trained","on","the","same","training","set","of","examples",".","..","seealso",":",":","Example","using","ensembles",":","`","node","classification","<","https",":","\/\/stellargraph.readthedocs.io\/en\/stable\/demos\/ensembles\/ensemble-node-classification-example.html",">","`","__",".","Related","functionality",":",":","class",":","`",".BaggingEnsemble","`","for","bootstrap","sampling","while","training",",","in","addition","to","random","initialisation","."]
docstr: This method trains the ensemble on the data specified by the generator. If validation data are given, then the
  training metrics are evaluated on these data and results printed on screen if verbose level is greater than 0.
  
  The method trains each model in the ensemble in series for the number of epochs specified. Training can
  also stop early with the best model as evaluated on the validation data, if use_early_stopping is set to True.
  
  For detail descriptions of Keras-specific parameters consult the Keras documentation
  at https://keras.io/models/sequential/
  
  Args:
      generator: The generator object for training data. It should be one of type
          NodeSequence, LinkSequence, SparseFullBatchSequence, or FullBatchSequence.
      steps_per_epoch (None or int): (Keras-specific parameter) If not None, it specifies the number of steps
          to yield from the generator before declaring one epoch finished and starting a new epoch.
      epochs (int): (Keras-specific parameter) The number of training epochs.
      verbose (int): (Keras-specific parameter) The verbosity mode that should be 0 , 1, or 2 meaning silent,
          progress bar, and one line per epoch respectively.
      validation_data: A generator for validation data that is optional (None). If not None then, it should
          be one of type NodeSequence, LinkSequence, SparseFullBatchSequence, or FullBatchSequence.
      validation_steps (None or int): (Keras-specific parameter) If validation_generator is not None, then it
          specifies the number of steps to yield from the generator before stopping at the end of every epoch.
      class_weight (None or dict): (Keras-specific parameter) If not None, it should be a dictionary
          mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during
          training only). This can be useful to tell the model to "pay more attention" to samples from an
          under-represented class.
      max_queue_size (int): (Keras-specific parameter) The maximum size for the generator queue.
      workers (int): (Keras-specific parameter) The maximum number of workers to use.
      use_multiprocessing (bool): (Keras-specific parameter) If True then use process based threading.
      shuffle (bool): (Keras-specific parameter) If True, then it shuffles the order of batches at the
          beginning of each training epoch.
      initial_epoch (int): (Keras-specific parameter) Epoch at which to start training (useful for resuming a
          previous training run).
      use_early_stopping (bool): If set to True, then early stopping is used when training each model
          in the ensemble. The default is False.
      early_stopping_monitor (str): The quantity to monitor for early stopping, e.g., 'val_loss',
          'val_weighted_acc'. It should be a valid Keras metric.
  
  Returns:
      list: It returns a list of Keras History objects each corresponding to one trained model in the ensemble.
docstr_tok: ["This","method","trains","the","ensemble","on","the","data","specified","by","the","generator",".","If","validation","data","are","given",",","then","the","training","metrics","are","evaluated","on","these","data","and","results","printed","on","screen","if","verbose","level","is","greater","than","0",".","The","method","trains","each","model","in","the","ensemble","in","series","for","the","number","of","epochs","specified",".","Training","can","also","stop","early","with","the","best","model","as","evaluated","on","the","validation","data",",","if","use_early_stopping","is","set","to","True",".","For","detail","descriptions","of","Keras-specific","parameters","consult","the","Keras","documentation","at","https",":","\/\/keras.io\/models\/sequential\/","Args",":","generator",":","The","generator","object","for","training","data",".","It","should","be","one","of","type","NodeSequence",",","LinkSequence",",","SparseFullBatchSequence",",","or","FullBatchSequence",".","steps_per_epoch","(","None","or","int",")",":","(","Keras-specific","parameter",")","If","not","None",",","it","specifies","the","number","of","steps","to","yield","from","the","generator","before","declaring","one","epoch","finished","and","starting","a","new","epoch",".","epochs","(","int",")",":","(","Keras-specific","parameter",")","The","number","of","training","epochs",".","verbose","(","int",")",":","(","Keras-specific","parameter",")","The","verbosity","mode","that","should","be","0",",","1",",","or","2","meaning","silent",",","progress","bar",",","and","one","line","per","epoch","respectively",".","validation_data",":","A","generator","for","validation","data","that","is","optional","(","None",")",".","If","not","None","then",",","it","should","be","one","of","type","NodeSequence",",","LinkSequence",",","SparseFullBatchSequence",",","or","FullBatchSequence",".","validation_steps","(","None","or","int",")",":","(","Keras-specific","parameter",")","If","validation_generator","is","not","None",",","then","it","specifies","the","number","of","steps","to","yield","from","the","generator","before","stopping","at","the","end","of","every","epoch",".","class_weight","(","None","or","dict",")",":","(","Keras-specific","parameter",")","If","not","None",",","it","should","be","a","dictionary","mapping","class","indices","(","integers",")","to","a","weight","(","float",")","value",",","used","for","weighting","the","loss","function","(","during","training","only",")",".","This","can","be","useful","to","tell","the","model","to","``","pay","more","attention","''","to","samples","from","an","under-represented","class",".","max_queue_size","(","int",")",":","(","Keras-specific","parameter",")","The","maximum","size","for","the","generator","queue",".","workers","(","int",")",":","(","Keras-specific","parameter",")","The","maximum","number","of","workers","to","use",".","use_multiprocessing","(","bool",")",":","(","Keras-specific","parameter",")","If","True","then","use","process","based","threading",".","shuffle","(","bool",")",":","(","Keras-specific","parameter",")","If","True",",","then","it","shuffles","the","order","of","batches","at","the","beginning","of","each","training","epoch",".","initial_epoch","(","int",")",":","(","Keras-specific","parameter",")","Epoch","at","which","to","start","training","(","useful","for","resuming","a","previous","training","run",")",".","use_early_stopping","(","bool",")",":","If","set","to","True",",","then","early","stopping","is","used","when","training","each","model","in","the","ensemble",".","The","default","is","False",".","early_stopping_monitor","(","str",")",":","The","quantity","to","monitor","for","early","stopping",",","e.g.",",","'val_loss","'",",","'val_weighted_acc","'",".","It","should","be","a","valid","Keras","metric",".","Returns",":","list",":","It","returns","a","list","of","Keras","History","objects","each","corresponding","to","one","trained","model","in","the","ensemble","."]
code: def fit(
      self,
      generator,
      steps_per_epoch=None,
      epochs=1,
      verbose=1,
      validation_data=None,
      validation_steps=None,
      class_weight=None,
      max_queue_size=10,
      workers=1,
      use_multiprocessing=False,
      shuffle=True,
      initial_epoch=0,
      use_early_stopping=False,
      early_stopping_monitor="val_loss",
  ):
      """
      This method trains the ensemble on the data specified by the generator. If validation data are given, then the
      training metrics are evaluated on these data and results printed on screen if verbose level is greater than 0.
  
      The method trains each model in the ensemble in series for the number of epochs specified. Training can
      also stop early with the best model as evaluated on the validation data, if use_early_stopping is set to True.
  
      For detail descriptions of Keras-specific parameters consult the Keras documentation
      at https://keras.io/models/sequential/
  
      Args:
          generator: The generator object for training data. It should be one of type
              NodeSequence, LinkSequence, SparseFullBatchSequence, or FullBatchSequence.
          steps_per_epoch (None or int): (Keras-specific parameter) If not None, it specifies the number of steps
              to yield from the generator before declaring one epoch finished and starting a new epoch.
          epochs (int): (Keras-specific parameter) The number of training epochs.
          verbose (int): (Keras-specific parameter) The verbosity mode that should be 0 , 1, or 2 meaning silent,
              progress bar, and one line per epoch respectively.
          validation_data: A generator for validation data that is optional (None). If not None then, it should
              be one of type NodeSequence, LinkSequence, SparseFullBatchSequence, or FullBatchSequence.
          validation_steps (None or int): (Keras-specific parameter) If validation_generator is not None, then it
              specifies the number of steps to yield from the generator before stopping at the end of every epoch.
          class_weight (None or dict): (Keras-specific parameter) If not None, it should be a dictionary
              mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during
              training only). This can be useful to tell the model to "pay more attention" to samples from an
              under-represented class.
          max_queue_size (int): (Keras-specific parameter) The maximum size for the generator queue.
          workers (int): (Keras-specific parameter) The maximum number of workers to use.
          use_multiprocessing (bool): (Keras-specific parameter) If True then use process based threading.
          shuffle (bool): (Keras-specific parameter) If True, then it shuffles the order of batches at the
              beginning of each training epoch.
          initial_epoch (int): (Keras-specific parameter) Epoch at which to start training (useful for resuming a
              previous training run).
          use_early_stopping (bool): If set to True, then early stopping is used when training each model
              in the ensemble. The default is False.
          early_stopping_monitor (str): The quantity to monitor for early stopping, e.g., 'val_loss',
              'val_weighted_acc'. It should be a valid Keras metric.
  
      Returns:
          list: It returns a list of Keras History objects each corresponding to one trained model in the ensemble.
  
      """
      if not isinstance(
          generator,
          (
              sg.mapper.NodeSequence,
              sg.mapper.LinkSequence,
              sg.mapper.FullBatchSequence,
              sg.mapper.SparseFullBatchSequence,
          ),
      ):
          raise ValueError(
              "({}) If train_data is None, generator must be one of type NodeSequence, LinkSequence, FullBatchSequence "
              "but received object of type {}".format(
                  type(self).__name__, type(generator).__name__
              )
          )
  
      self.history = []
  
      es_callback = None
      if use_early_stopping and validation_data is not None:
          es_callback = [
              EarlyStopping(
                  monitor=early_stopping_monitor,
                  patience=self.early_stoppping_patience,
                  restore_best_weights=True,
              )
          ]
  
      for model in self.models:
          self.history.append(
              model.fit(
                  generator,
                  steps_per_epoch=steps_per_epoch,
                  epochs=epochs,
                  verbose=verbose,
                  callbacks=es_callback,
                  validation_data=validation_data,
                  validation_steps=validation_steps,
                  class_weight=class_weight,
                  max_queue_size=max_queue_size,
                  workers=workers,
                  use_multiprocessing=use_multiprocessing,
                  shuffle=shuffle,
                  initial_epoch=initial_epoch,
              )
          )
  
      return self.history
  
imports: from stellargraph.layer import *
  import numpy
  from tensorflow import keras
  from tensorflow.keras.callbacks import EarlyStopping
  import stellargraph
label_desc: Use image node_id 5 for calling the Ensemble obj's underlying member method code with example usage: obj.fit(generator, steps_per_epoch, epochs, verbose, validation_data, validation_steps, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch, use_early_stopping, early_stopping_monitor) and returns: self