docstr: Handles initialization, fitting, and prediction for provided algorithms. Consider
  documentation for children of :class:`Model` to be identical to that of :class:`Model`,
  except where noted
  
  Parameters
  ----------
  model_initializer: Class
      Expected to implement at least the following methods: 1) `__init__`, to which
      :attr:`initialization_params` will usually be provided unless stated otherwise in a
      child class's documentation - like :class:`KerasModel`. 2) `fit`, to which
      :attr:`train_input`, and :attr:`train_target` will be provided, in addition to the
      contents of :attr:`extra_params['fit']` in some child classes - like
      :class:`XGBoostModel`. 3) `predict`, or `predict_proba` if applicable, which should
      accept any array-like input of shape: (<num_samples>, `train_input.shape[1]`)
  initialization_params: Dict
      A dict containing all arguments accepted by :meth:`__init__` of the class
      :attr:`model_initializer`, unless stated otherwise in a child class's documentation -
      like :class:`KerasModel`. Arguments pertaining to random seeds will be ignored
  extra_params: Dict, default={}
      A dict of special parameters that are passed to a model's non-initialization methods in
      special cases (such as `fit`, `predict`, `predict_proba`, and `score`). `extra_params`
      are not used for all models. See the documentation for the appropriate descendant of
      :class:`models.Model` for information about how it handles `extra_params`
  train_input: `pandas.DataFrame`
      The model's training input data
  train_target: `pandas.DataFrame`
      The true labels corresponding to the rows of :attr:`train_input`
  validation_input: `pandas.DataFrame`, or None
      The model's validation input data to evaluate performance during fitting
  validation_target: `pandas.DataFrame`, or None
      The true labels corresponding to the rows of :attr:`validation_input`
  do_predict_proba: Boolean, or int, default=False
      * If False, :meth:`.models.Model.fit` will call :meth:`models.Model.model.predict`
      * If True, it will call :meth:`models.Model.model.predict_proba`, and the values in all
        columns will be used as the actual prediction values
      * If `do_predict_proba` is an int, :meth:`.models.Model.fit` will call
        :meth:`models.Model.model.predict_proba`, as is the case when `do_predict_proba` is
        True, but the int supplied as `do_predict_proba` declares the column index to use as
        the actual prediction values
      * For example, for a model to call the `predict` method, `do_predict_proba=False`
        (default). For a model to call the `predict_proba` method, and use all of the class
        probabilities, `do_predict_proba=True`. To call the `predict_proba` method, and use
        the class probabilities in the first column, `do_predict_proba=0`. To use the second
        column (index 1) of the result, `do_predict_proba=1` - This often corresponds to the
        positive class's probabilities in binary classification problems. To use the third
        column `do_predict_proba=2`, and so on
      * See the notes for the `do_predict_proba` parameter in the documentation of
        :class:`environment.Environment` for additional usage notes
  target_metric: Tuple
      Used by some child classes (like :class:`XGBoostModel`) to provide validation data to
      :meth:`model.fit`
  metrics: Dict
      Used by some child classes (like :class:`XGBoostModel`) to provide validation data to
      :meth:`model.fit`
docstr_tok: ["Handles","initialization",",","fitting",",","and","prediction","for","provided","algorithms",".","Consider","documentation","for","children","of",":","class",":","`","Model","`","to","be","identical","to","that","of",":","class",":","`","Model","`",",","except","where","noted","Parameters","--","--","--","--","--","model_initializer",":","Class","Expected","to","implement","at","least","the","following","methods",":","1",")","`","__init__","`",",","to","which",":","attr",":","`","initialization_params","`","will","usually","be","provided","unless","stated","otherwise","in","a","child","class","'s","documentation","-","like",":","class",":","`","KerasModel","`",".","2",")","`","fit","`",",","to","which",":","attr",":","`","train_input","`",",","and",":","attr",":","`","train_target","`","will","be","provided",",","in","addition","to","the","contents","of",":","attr",":","`","extra_params","[","'fit","'","]","`","in","some","child","classes","-","like",":","class",":","`","XGBoostModel","`",".","3",")","`","predict","`",",","or","`","predict_proba","`","if","applicable",",","which","should","accept","any","array-like","input","of","shape",":","(","<","num_samples",">",",","`","train_input.shape","[","1","]","`",")","initialization_params",":","Dict","A","dict","containing","all","arguments","accepted","by",":","meth",":","`","__init__","`","of","the","class",":","attr",":","`","model_initializer","`",",","unless","stated","otherwise","in","a","child","class","'s","documentation","-","like",":","class",":","`","KerasModel","`",".","Arguments","pertaining","to","random","seeds","will","be","ignored","extra_params",":","Dict",",","default=","{","}","A","dict","of","special","parameters","that","are","passed","to","a","model","'s","non-initialization","methods","in","special","cases","(","such","as","`","fit","`",",","`","predict","`",",","`","predict_proba","`",",","and","`","score","`",")",".","`","extra_params","`","are","not","used","for","all","models",".","See","the","documentation","for","the","appropriate","descendant","of",":","class",":","`","models.Model","`","for","information","about","how","it","handles","`","extra_params","`","train_input",":","`","pandas.DataFrame","`","The","model","'s","training","input","data","train_target",":","`","pandas.DataFrame","`","The","true","labels","corresponding","to","the","rows","of",":","attr",":","`","train_input","`","validation_input",":","`","pandas.DataFrame","`",",","or","None","The","model","'s","validation","input","data","to","evaluate","performance","during","fitting","validation_target",":","`","pandas.DataFrame","`",",","or","None","The","true","labels","corresponding","to","the","rows","of",":","attr",":","`","validation_input","`","do_predict_proba",":","Boolean",",","or","int",",","default=False","*","If","False",",",":","meth",":","`",".models.Model.fit","`","will","call",":","meth",":","`","models.Model.model.predict","`","*","If","True",",","it","will","call",":","meth",":","`","models.Model.model.predict_proba","`",",","and","the","values","in","all","columns","will","be","used","as","the","actual","prediction","values","*","If","`","do_predict_proba","`","is","an","int",",",":","meth",":","`",".models.Model.fit","`","will","call",":","meth",":","`","models.Model.model.predict_proba","`",",","as","is","the","case","when","`","do_predict_proba","`","is","True",",","but","the","int","supplied","as","`","do_predict_proba","`","declares","the","column","index","to","use","as","the","actual","prediction","values","*","For","example",",","for","a","model","to","call","the","`","predict","`","method",",","`","do_predict_proba=False","`","(","default",")",".","For","a","model","to","call","the","`","predict_proba","`","method",",","and","use","all","of","the","class","probabilities",",","`","do_predict_proba=True","`",".","To","call","the","`","predict_proba","`","method",",","and","use","the","class","probabilities","in","the","first","column",",","`","do_predict_proba=0","`",".","To","use","the","second","column","(","index","1",")","of","the","result",",","`","do_predict_proba=1","`","-","This","often","corresponds","to","the","positive","class","'s","probabilities","in","binary","classification","problems",".","To","use","the","third","column","`","do_predict_proba=2","`",",","and","so","on","*","See","the","notes","for","the","`","do_predict_proba","`","parameter","in","the","documentation","of",":","class",":","`","environment.Environment","`","for","additional","usage","notes","target_metric",":","Tuple","Used","by","some","child","classes","(","like",":","class",":","`","XGBoostModel","`",")","to","provide","validation","data","to",":","meth",":","`","model.fit","`","metrics",":","Dict","Used","by","some","child","classes","(","like",":","class",":","`","XGBoostModel","`",")","to","provide","validation","data","to",":","meth",":","`","model.fit","`"]
code: def __init__(
      self,
      model_initializer,
      initialization_params,
      extra_params,
      train_input=None,
      train_target=None,
      validation_input=None,
      validation_target=None,
      do_predict_proba=False,
      target_metric=None,
      metrics=None,
  ):
      """Handles initialization, fitting, and prediction for provided algorithms. Consider
      documentation for children of :class:`Model` to be identical to that of :class:`Model`,
      except where noted
  
      Parameters
      ----------
      model_initializer: Class
          Expected to implement at least the following methods: 1) `__init__`, to which
          :attr:`initialization_params` will usually be provided unless stated otherwise in a
          child class's documentation - like :class:`KerasModel`. 2) `fit`, to which
          :attr:`train_input`, and :attr:`train_target` will be provided, in addition to the
          contents of :attr:`extra_params['fit']` in some child classes - like
          :class:`XGBoostModel`. 3) `predict`, or `predict_proba` if applicable, which should
          accept any array-like input of shape: (<num_samples>, `train_input.shape[1]`)
      initialization_params: Dict
          A dict containing all arguments accepted by :meth:`__init__` of the class
          :attr:`model_initializer`, unless stated otherwise in a child class's documentation -
          like :class:`KerasModel`. Arguments pertaining to random seeds will be ignored
      extra_params: Dict, default={}
          A dict of special parameters that are passed to a model's non-initialization methods in
          special cases (such as `fit`, `predict`, `predict_proba`, and `score`). `extra_params`
          are not used for all models. See the documentation for the appropriate descendant of
          :class:`models.Model` for information about how it handles `extra_params`
      train_input: `pandas.DataFrame`
          The model's training input data
      train_target: `pandas.DataFrame`
          The true labels corresponding to the rows of :attr:`train_input`
      validation_input: `pandas.DataFrame`, or None
          The model's validation input data to evaluate performance during fitting
      validation_target: `pandas.DataFrame`, or None
          The true labels corresponding to the rows of :attr:`validation_input`
      do_predict_proba: Boolean, or int, default=False
          * If False, :meth:`.models.Model.fit` will call :meth:`models.Model.model.predict`
          * If True, it will call :meth:`models.Model.model.predict_proba`, and the values in all
            columns will be used as the actual prediction values
          * If `do_predict_proba` is an int, :meth:`.models.Model.fit` will call
            :meth:`models.Model.model.predict_proba`, as is the case when `do_predict_proba` is
            True, but the int supplied as `do_predict_proba` declares the column index to use as
            the actual prediction values
          * For example, for a model to call the `predict` method, `do_predict_proba=False`
            (default). For a model to call the `predict_proba` method, and use all of the class
            probabilities, `do_predict_proba=True`. To call the `predict_proba` method, and use
            the class probabilities in the first column, `do_predict_proba=0`. To use the second
            column (index 1) of the result, `do_predict_proba=1` - This often corresponds to the
            positive class's probabilities in binary classification problems. To use the third
            column `do_predict_proba=2`, and so on
          * See the notes for the `do_predict_proba` parameter in the documentation of
            :class:`environment.Environment` for additional usage notes
      target_metric: Tuple
          Used by some child classes (like :class:`XGBoostModel`) to provide validation data to
          :meth:`model.fit`
      metrics: Dict
          Used by some child classes (like :class:`XGBoostModel`) to provide validation data to
          :meth:`model.fit`"""
      self.model_initializer = model_initializer
      self.initialization_params = initialization_params
      self.extra_params = extra_params or {}
  
      self.train_input = train_input
      self.train_target = train_target
      self.validation_input = validation_input
      self.validation_target = validation_target
      self.do_predict_proba = do_predict_proba
      self.target_metric = target_metric
      self.metrics = metrics
  
      self.model = None
      self.epochs_elapsed = None
  
      self.initialization_params = locate_sentinels(
          self.initialization_params
      )
      self.extra_params = locate_sentinels(self.extra_params)
  
      self.initialize_model()
  
imports: from hyperparameter_hunter.sentinels import locate_sentinels
  from hyperparameter_hunter.settings import G
  from contextlib import suppress
  import inspect
  import sys
  import warnings
  import sklearn.utils
label_desc: Use image node_id 1 to create a new Model object from inherited base classes: object with example: obj = Model(model_initializer, initialization_params, extra_params, train_input, train_target, validation_input, validation_target, do_predict_proba, target_metric, metrics)