code: def gain(category, attr):
      cats = []
      for i in range(len(attr)):
          if not attr[i] == "?":
              cats.append([float(attr[i]), category[i]])
      cats = sorted(cats, key=lambda x: x[0])
  
      cat = [cats[i][1] for i in range(len(cats))]
      att = [cats[i][0] for i in range(len(cats))]
      if len(set(att)) == 1:
          return 0
      else:
          gains = []
          div_point = []
          for i in range(1, len(cat)):
              if not att[i] == att[i - 1]:
                  gains.append(
                      entropy(cat[:i]) * float(i) / len(cat)
                      + entropy(cat[i:]) * (1 - float(i) / len(cat))
                  )
                  div_point.append(i)
          gain = entropy(cat) - min(gains)
  
          p_1 = float(div_point[gains.index(min(gains))]) / len(cat)
          ent_attr = -p_1 * math.log(p_1, 2) - (1 - p_1) * math.log(
              (1 - p_1), 2
          )
          return gain / ent_attr
  
file_path: imodels/imodels/tree/c45_tree/c45_utils.py
imports: import math
label_desc: Use image node_id 6 for calling a global function with example usage: gain(category, attr) and returns: int, unknown