docstr: A special Model class for handling Keras neural networks. Consider documentation to be
  identical to that of :class:`Model`, except where noted
  
  Parameters
  ----------
  model_initializer: :class:`keras.wrappers.scikit_learn.KerasClassifier`, or `keras.wrappers.scikit_learn.KerasRegressor`
      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 containing `build_fn`
      A dictionary containing the single key: `build_fn`, which is a callable function that
      returns a compiled Keras model
  extra_params: Dict, default={}
      The parameters expected to be passed to the extra methods of the compiled Keras model.
      Such methods include (but are not limited to) `fit`, `predict`, and `predict_proba`.
      Some of the common parameters given here include `epochs`, `batch_size`, and `callbacks`
  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 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 of
      :class:`~hyperparameter_hunter.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: ["A","special","Model","class","for","handling","Keras","neural","networks",".","Consider","documentation","to","be","identical","to","that","of",":","class",":","`","Model","`",",","except","where","noted","Parameters","--","--","--","--","--","model_initializer",":",":","class",":","`","keras.wrappers.scikit_learn.KerasClassifier","`",",","or","`","keras.wrappers.scikit_learn.KerasRegressor","`","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","containing","`","build_fn","`","A","dictionary","containing","the","single","key",":","`","build_fn","`",",","which","is","a","callable","function","that","returns","a","compiled","Keras","model","extra_params",":","Dict",",","default=","{","}","The","parameters","expected","to","be","passed","to","the","extra","methods","of","the","compiled","Keras","model",".","Such","methods","include","(","but","are","not","limited","to",")","`","fit","`",",","`","predict","`",",","and","`","predict_proba","`",".","Some","of","the","common","parameters","given","here","include","`","epochs","`",",","`","batch_size","`",",","and","`","callbacks","`","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","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","of",":","class",":","`","~hyperparameter_hunter.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,
  ):
      """A special Model class for handling Keras neural networks. Consider documentation to be
      identical to that of :class:`Model`, except where noted
  
      Parameters
      ----------
      model_initializer: :class:`keras.wrappers.scikit_learn.KerasClassifier`, or `keras.wrappers.scikit_learn.KerasRegressor`
          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 containing `build_fn`
          A dictionary containing the single key: `build_fn`, which is a callable function that
          returns a compiled Keras model
      extra_params: Dict, default={}
          The parameters expected to be passed to the extra methods of the compiled Keras model.
          Such methods include (but are not limited to) `fit`, `predict`, and `predict_proba`.
          Some of the common parameters given here include `epochs`, `batch_size`, and `callbacks`
      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 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 of
          :class:`~hyperparameter_hunter.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`"""
      if model_initializer.__name__ not in (
          "KerasClassifier",
          "KerasRegressor",
      ):
          raise ValueError(
              f"Invalid `model_initializer`: {model_initializer}"
          )
  
      self.model_history = None
  
      super().__init__(
          model_initializer,
          initialization_params,
          extra_params,
          train_input=train_input,
          train_target=train_target,
          validation_input=validation_input,
          validation_target=validation_target,
          do_predict_proba=do_predict_proba,
          target_metric=target_metric,
          metrics=metrics,
      )
  
      global load_model
      from keras.models import load_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 KerasModel object from inherited base classes: Model with example: obj = KerasModel(model_initializer, initialization_params, extra_params, train_input, train_target, validation_input, validation_target, do_predict_proba, target_metric, metrics)