def discrimination(prob, outcome, n_bins=10):
 prob = np.array(prob)
 outcome = np.array(outcome)
 d = 0.0
 base_prob = np.mean(outcome)
 judgement_bins = (np.arange((n_bins + 1)) / n_bins)
 bin_num = np.digitize(prob, judgement_bins)
 for j_bin in np.unique(bin_num):
  in_bin = (bin_num == j_bin)
  true_bin_prob = np.mean(outcome[in_bin])
  d += (np.sum(in_bin) * ((true_bin_prob - base_prob) ** 2))
 return (d / len(prob))

def discrimination ( prob , outcome , n_bins = 10 ) : prob = np . array ( prob ) outcome = np . array ( outcome ) d = 0.0 base_prob = np . mean ( outcome ) judgement_bins = ( np . arange ( ( n_bins + 1 ) ) / n_bins ) bin_num = np . digitize ( prob , judgement_bins ) for j_bin in np . unique ( bin_num ) : in_bin = ( bin_num == j_bin ) true_bin_prob = np . mean ( outcome [ in_bin ] ) d += ( np . sum ( in_bin ) * ( ( true_bin_prob - base_prob ) ** 2 ) ) return ( d / len ( prob ) )
discrimination measurement for a set of predictions .