class_docstr: Grouped Conditional Expectation plots are generated for a given instance and set of features.
  They show how the model prediction is affected when a pair of features of a given instance are
  perturbed. The perturbed features can be either a provided subset of the input covariates, or
  the top K features based on the importance rank obtained by a global explainer (e.g., SHAP).
  If the user provides a single feature then the algorithm produces a standard ICE plot where the
  selected feature varies according to a linespace grid. If the user chooses more than one feature,
  then the explainer produces 3D ICE plots. Here, two features vary simultaneously according to a
  meshgrid, the output of the model is stored for each pair of values.
code: def fit(self, X: pd.DataFrame, *args, **kwargs):
      np.random.seed(self.random_seed)
      # compute feature ranges from input data
      for f in self.feature_names:
          self.feature_range[f] = {
              "min": np.min(X[f].values),
              "max": np.max(X[f].values),
          }
  
      ## If we want to consider top K importance features
      if len(self.features_selected) == 0:
          if self.top_k_features <= 0:  ## All features
              self.features_selected = self.feature_names
          else:
              ## feature selection based on shap importance
              if (
                  self.feature_importance_method == "SHAP"
              ):  ## SHAP OPTION
                  shap_data = X
                  if shap_data.shape[0] > self.max_dataset_size:
                      shap_data = self._partition_sample(
                          np.asarray(shap_data), self.max_dataset_size
                      )
                      shap_data = pd.DataFrame(
                          shap_data, columns=X.columns
                      )
                  shap_exp = shap.KernelExplainer(
                      self.model,
                      shap_data,
                      link="identity",
                      algorithm="auto",
                  )
                  shap_values = shap_exp.shap_values(
                      shap_data, nsamples=50
                  )
  
                  features_importance = (
                      np.abs(shap_values).mean(axis=0).tolist()
                  )
                  features_names = self.feature_names
  
                  ## Save names of top K importance features
                  self.features_selected = [
                      features_names[int(_)]
                      for _ in np.argsort(
                          np.array(features_importance)
                      )[-self.top_k_features :]
                  ]
                  self.features_selected = list(
                      set(self.features_selected)
                  )
  
                  print(
                      "Considering Top {} features according to SHAP: {}".format(
                          self.top_k_features, self.features_selected
                      )
                  )
  
      self._is_fitted = True
      return self
  
file_path: AIX360/aix360/algorithms/gce/gce.py
imports: import warnings
  from typing import List, Union, Callable
  import numpy
  import pandas
  import shap
  from aix360.algorithms.lbbe import LocalBBExplainer
label_desc: Use image node_id 2 for calling the GroupedCEExplainer obj's underlying member method code with example usage: obj.fit(X) and returns: self