class_docstr: The main explainer class that implements functions for computation of sample-wise weights from probe confidences of different layers from
  the complex model and then retrains the simple model with those weights. Implements the technique in the following reference: [#]_.
  
  References:
      .. [#] `Dhurandhar, Shanmugam, Luss, Olsen. Improving Simple Models with Confidence Profiles. NeurIPS 2018 <https://arxiv.org/abs/1807.07506>`_
docstr: Obtains (train) sample-wise weights from stored probe confidences for different layers of the complex moddel. Retrains a simple
  model using the corresponding weighted training set.
  
  Parameters:
      x_train (numpy array): Dataset of features to retrain the simple model using weights derived from probe confidences. Dimensions (num of samples x feature dimensions)
      y_train (numpy array): Labels for the dataset that is used to retrain simple model using weights. Dimensions (num of samples x num of classes)
      x_test (numpy array): Test dataset to evaluate the simple model trained using weights. Dimensions (num of samples x feature dimensions)
      y_test (numpy array): Test labels to evaulate the simple model trained using weights. Dimensions (num of samples x num of classes)
      hps (namedtuple): Hyperparameters (usually a named tuple with entries) to train the simple model. Please see fit function to
          find out the required set of parameters expected by the fit function.
      list_probe_filenames (list of strings): List of strings indicated path to files where different probe confidences are stored.
      start_layer (int): Index corresponding to the starting layer whose probe confidences are going to be averaged to obtain weights.
          This is an index of list_probe_filenames.
      end_layer (int): Index corresponding to the last layer whose probe confidences are going to be averaged to obtain weights. This is an index of list_probe_filenames.
      model_type (string): This specifies the type of simple model to be trained. Default is 'neural_keras'. Only this option is implemented now.
      simple_model (function object for a Keras model): This is a function object that would initialize a keras model to specify the architecture of the simple model.
  
  Returns:
      None
docstr_tok: ["Obtains","(","train",")","sample-wise","weights","from","stored","probe","confidences","for","different","layers","of","the","complex","moddel",".","Retrains","a","simple","model","using","the","corresponding","weighted","training","set",".","Parameters",":","x_train","(","numpy","array",")",":","Dataset","of","features","to","retrain","the","simple","model","using","weights","derived","from","probe","confidences",".","Dimensions","(","num","of","samples","x","feature","dimensions",")","y_train","(","numpy","array",")",":","Labels","for","the","dataset","that","is","used","to","retrain","simple","model","using","weights",".","Dimensions","(","num","of","samples","x","num","of","classes",")","x_test","(","numpy","array",")",":","Test","dataset","to","evaluate","the","simple","model","trained","using","weights",".","Dimensions","(","num","of","samples","x","feature","dimensions",")","y_test","(","numpy","array",")",":","Test","labels","to","evaulate","the","simple","model","trained","using","weights",".","Dimensions","(","num","of","samples","x","num","of","classes",")","hps","(","namedtuple",")",":","Hyperparameters","(","usually","a","named","tuple","with","entries",")","to","train","the","simple","model",".","Please","see","fit","function","to","find","out","the","required","set","of","parameters","expected","by","the","fit","function",".","list_probe_filenames","(","list","of","strings",")",":","List","of","strings","indicated","path","to","files","where","different","probe","confidences","are","stored",".","start_layer","(","int",")",":","Index","corresponding","to","the","starting","layer","whose","probe","confidences","are","going","to","be","averaged","to","obtain","weights",".","This","is","an","index","of","list_probe_filenames",".","end_layer","(","int",")",":","Index","corresponding","to","the","last","layer","whose","probe","confidences","are","going","to","be","averaged","to","obtain","weights",".","This","is","an","index","of","list_probe_filenames",".","model_type","(","string",")",":","This","specifies","the","type","of","simple","model","to","be","trained",".","Default","is","'neural_keras","'",".","Only","this","option","is","implemented","now",".","simple_model","(","function","object","for","a","Keras","model",")",":","This","is","a","function","object","that","would","initialize","a","keras","model","to","specify","the","architecture","of","the","simple","model",".","Returns",":","None"]
code: def explain(
      self,
      x_train,
      y_train,
      x_test,
      y_test,
      simple_model,
      hps,
      list_probe_filenames,
      start_layer,
      end_layer,
      model_type="neural_keras",
  ):
      """
      Obtains (train) sample-wise weights from stored probe confidences for different layers of the complex moddel. Retrains a simple
      model using the corresponding weighted training set.
  
      Parameters:
          x_train (numpy array): Dataset of features to retrain the simple model using weights derived from probe confidences. Dimensions (num of samples x feature dimensions)
          y_train (numpy array): Labels for the dataset that is used to retrain simple model using weights. Dimensions (num of samples x num of classes)
          x_test (numpy array): Test dataset to evaluate the simple model trained using weights. Dimensions (num of samples x feature dimensions)
          y_test (numpy array): Test labels to evaulate the simple model trained using weights. Dimensions (num of samples x num of classes)
          hps (namedtuple): Hyperparameters (usually a named tuple with entries) to train the simple model. Please see fit function to
              find out the required set of parameters expected by the fit function.
          list_probe_filenames (list of strings): List of strings indicated path to files where different probe confidences are stored.
          start_layer (int): Index corresponding to the starting layer whose probe confidences are going to be averaged to obtain weights.
              This is an index of list_probe_filenames.
          end_layer (int): Index corresponding to the last layer whose probe confidences are going to be averaged to obtain weights. This is an index of list_probe_filenames.
          model_type (string): This specifies the type of simple model to be trained. Default is 'neural_keras'. Only this option is implemented now.
          simple_model (function object for a Keras model): This is a function object that would initialize a keras model to specify the architecture of the simple model.
  
      Returns:
          None
  
      """
  
      w = prof_weight_compute(
          list_probe_filenames, start_layer, end_layer, y_train
      )
      # Train the simple model with Weights
      assert hasattr(
          hps, "checkpoint_path"
      ), "Checkpoint to save not mentioned"
      m = self.fit(
          x_train,
          y_train,
          x_test,
          y_test,
          simple_model,
          hps,
          "neural_keras",
          w.reshape(
              w.shape[0],
          ),
      )
      print("Accuracy of Prof-Weighted Simple Model:", m[1])
      self._model = m[0]
      return
  
file_path: AIX360/aix360/algorithms/profwt/profwt.py
imports: from aix360.algorithms.gwbe import GlobalWBExplainer
  import numpy
  import keras
  from keras.callbacks import ModelCheckpoint
  from keras.layers import Dense, Conv2D, BatchNormalization, Activation
  from keras.layers import AveragePooling2D, Input, Flatten
  from keras.optimizers import Adam
  from keras.models import Model
  from keras import backend
  from aix360.algorithms.profwt.sample_weight_from_probes import prof_weight_compute
label_desc: Use image node_id 3 for calling the ProfweightExplainer obj's underlying member method code with example usage: obj.explain(x_train, y_train, x_test, y_test, simple_model, hps, list_probe_filenames, start_layer, end_layer, model_type) without return types