code: def get_importance_per_top_groups(ebm, X):
      """Returns a Dataframe with the importances of groups of terms, such that:
  
      The first group is the term with the highest individual importance (i.e. top term), the second group is
      composed by the top 2 terms, and so on. For example:
          Group 1 - ['Age']
          Group 2 - ['Age', 'MaritalStatus']
          Group 3 - ['Age', 'MaritalStatus', 'CapitalGain']
          ...
          Group N - All terms
  
      Args:
          ebm: A fitted EBM
          X (numpy array): Samples used to compute the group importance
  
      Returns:
         a pandas Dataframe with three columns: group_names, terms_per_group and importances
      """
      contributions = ebm.eval_terms(X)
      individual_importances = get_individual_importances(
          ebm, X, contributions
      )
  
      # Create groups of terms starting with the most important and adding each subsequent term
      groups_list = []
      temp_group = []
      for key in individual_importances.keys():
          if len(temp_group) > 0:
              temp_group = list(groups_list[-1])
          temp_group.append(key)
          groups_list.append(temp_group)
  
      # Compute the importance of each group in groups_list
      group_index = 1
      output_dict = {}
      for group in groups_list:
          group_name = f"Group {group_index}"
          output_dict[group_name] = compute_group_importance(
              group, ebm, X, contributions
          )
          group_index += 1
  
      df = pd.DataFrame(
          {
              "groups": output_dict.keys(),
              "terms_per_group": groups_list,
              "importances": output_dict.values(),
          }
      )
  
      return df
  
file_path: interpret/python/interpret-core/interpret/glassbox/_ebm/_research/_group_importance.py
imports: import numpy
  import pandas
  import plotly.express
  from sklearn.utils.validation import check_is_fitted
label_desc: Use image node_id 6 for calling a global function with example usage: get_importance_per_top_groups(ebm, X) and returns: df