code: def addLabelsAndExplanations(dataset, rules):
      """This function will use a ruleset to add labels (Y) and explanations/rules (E) to a passed dataset
      Arg:
          dataset (list of lists) : a list of feature vectors (list)
          rules (list of lists) : a list of rules
      """
  
      noMatches = 0  # Counters to record how often there are no (Yes) matches, 1 (Yes) match, and multiple (Yes) matches
      multiMatches = 0
      oneMatches = 0
      for instance in dataset:
          ruleMatches = findRule(instance, rules)
  
          if (
              len(ruleMatches) == 0
          ):  # We didn't match a (Yes) rule, so this ia No situation
              rule = NoRiskRuleNum
              label = No
              noMatches += 1
          elif (
              len(ruleMatches) > 1
          ):  # Matched multiple Yes rules, need to pick one
              rule = pickBestRule(ruleMatches)
              assert rule >= 0 and rule < len(
                  rules
              )  # Ensure rule number is valid
              label = Yes
              multiMatches += 1
          else:  # Found 1 Yes rule match, it's the winner
              rule = ruleMatches[0]
              label = Yes
              oneMatches += 1
              assert rule >= 0 and rule < len(
                  rules
              )  # Ensure rule number is valid
  
          # print("Label: " + ruleValToString(label) + ", Rule: " + ruleValToString(rule))
  
          instance.append(label)
          instance.append(
              rule
          )  # add the label and explanation (rule #) to the featureVector
  
      if True:
          print("\nRule matching statistics: ")
          totalYes = oneMatches + multiMatches
          total = oneMatches + multiMatches + noMatches
          print(
              "  Yes Labels: {}/{} ({:.2f}%)".format(
                  totalYes, total, totalYes / total * 100
              )
          )
          print(
              "    Matched 1 Yes rule: {}/{} ({:.2f}%)".format(
                  oneMatches, totalYes, oneMatches / totalYes * 100
              )
          )
          print(
              "    Matched multiple Yes rules: {}/{} ({:.2f}%)".format(
                  multiMatches, totalYes, multiMatches / totalYes * 100
              )
          )
          print(
              "  No Laels: {}/{} ({:.2f}%)".format(
                  noMatches, total, noMatches / total * 100
              )
          )
  
file_path: AIX360/aix360/data/ted_data/GenerateData.py
imports: import random
  from random import choices
  import pandas
label_desc: Use image node_id 15 for calling a global function with example usage: addLabelsAndExplanations(dataset, rules) without return types