Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def GAP(pred, conf, true):
- x = pd.DataFrame({'pred': pred, 'conf': conf, 'true': true})
- x.sort_values('conf', ascending=False, inplace=True, na_position='last')
- x['correct'] = (x.true == x.pred).astype(int)
- x['prec_k'] = x.correct.cumsum() / (np.arange(len(x)) + 1)
- x['term'] = x.prec_k * x.correct
- gap = x.term.sum() / x.true.count()
- return gap
- model.compile(loss='my_loss',metrics=[GAP])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement