code: def gain_ratio(category, attr):
      s = 0
      cat = []
      att = []
      for i in range(len(attr)):
          if not attr[i] == "?":
              cat.append(category[i])
              att.append(attr[i])
      for i in set(att):
          p_i = float(att.count(i)) / len(att)
          cat_i = []
          for j in range(len(cat)):
              if att[j] == i:
                  cat_i.append(cat[j])
          s = s + p_i * entropy(cat_i)
      gain = entropy(cat) - s
      ent_att = entropy(att)
      if ent_att == 0:
          return 0
      else:
          return gain / ent_att
  
file_path: imodels/imodels/tree/c45_tree/c45_utils.py
imports: import math
label_desc: Use image node_id 5 for calling a global function with example usage: gain_ratio(category, attr) and returns: int, unknown