def compute_sb(y_true, y_pred, sample_weight):
    total_s = numpy.sum(sample_weight[y_true > 0.5])
    total_b = numpy.sum(sample_weight[y_true < 0.5])
    s = sample_weight[y_true * y_pred > 0.5].sum()
    b = sample_weight[(1 - y_true) * y_pred > 0.5].sum()
    return s / total_s, b / total_b
Here the passed arguments should be already checked, y_pred is array of 0 and 1
dataset/ETHPy150Open anaderi/lhcb_trigger_ml/hep_ml/metrics.py/compute_sb