code: def compute_ruleset_metrics(
      ruleset: DnfRuleSet, X: pd.DataFrame, y: pd.Series
  ):
      """
      Compute ruleset-level confusion matrix and accuracy when used as a binary classifier
  
      @param X: features
      @param y: labels
      @return: a dict describing the confusion matrix and accuracy
      """
      then_part = ruleset.then_part
      y_true = y == then_part
      y_pred = batch_evaluate(ruleset, X)
      tn, fp, fn, tp = confusion_matrix(y_true, y_pred).ravel()
      accuracy = (tn + tp) / len(y)
      return {
          "tn": tn,
          "fp": fp,
          "fn": fn,
          "tp": tp,
          "accuracy": accuracy,
      }
  
file_path: AIX360/aix360/algorithms/rule_induction/trxf/metrics.py
imports: from collections import namedtuple
  from copy import deepcopy
  from typing import List
  import numpy
  import pandas
  from sklearn.metrics import confusion_matrix
  from aix360.algorithms.rule_induction.trxf.core.dnf_ruleset import DnfRuleSet
  from aix360.algorithms.rule_induction.trxf.core.utils import batch_evaluate
label_desc: Use image node_id 1 for calling a global function with example usage: compute_ruleset_metrics(ruleset, X, y) and returns: dict