code: def B_calc(classes, TP, TOP, P):
      """
      Calculate Bangdiwala's B (B).
  
      :param classes: confusion matrix classes
      :type classes: list
      :param TP: true positive
      :type TP: dict
      :param TOP: number of positives in predict vector per class
      :type TOP: dict
      :param P: number of actual positives per class
      :type P: dict
      :return: B as float
      """
      try:
          up = 0
          down = 0
          for i in classes:
              up += TP[i] ** 2
              down += TOP[i] * P[i]
          B = up / down
          return B
      except Exception:
          return "None"
  
imports: from __future__ import division
  import math
  import operator
  from functools import reduce
  from .pycm_interpret import *
  from .pycm_ci import kappa_SE_calc, CI_calc, SE_calc
  from .pycm_util import complement
label_desc: Use image node_id 6 for calling a global function with example usage: B_calc(classes, TP, TOP, P) and returns: B, str