docstr: Calculates feature importances for each treatment group, based on the permutation method.
docstr_tok: ["Calculates","feature","importances","for","each","treatment","group",",","based","on","the","permutation","method","."]
code: def perm_importance(self):
      """
      Calculates feature importances for each treatment group, based on the permutation method.
      """
      importance_dict = {}
      if self.r_learners is not None:
          self.models_tau = deepcopy(self.r_learners)
          self.X_test, self.tau_test = self.X, self.tau
      for group, idx in self.classes.items():
          perm_estimator = self.models_tau[group]
          importance_dict[group] = permutation_importance(
              estimator=perm_estimator,
              X=self.X_test,
              y=self.tau_test[:, idx],
              random_state=self.random_state,
          ).importances_mean
  
      return importance_dict
  
imports: import pandas
  import shap
  import matplotlib.pyplot
  from lightgbm import LGBMRegressor
  from sklearn.inspection import permutation_importance
  from sklearn.model_selection import train_test_split
  from copy import deepcopy
  from causalml.inference.meta.utils import convert_pd_to_np
label_desc: Use image node_id 7 for calling the Explainer obj's underlying member method code with example usage: obj.perm_importance() and returns: importance_dict