Guest User

Untitled

a guest
Oct 23rd, 2019
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def focal_loss_lgb_eval_error(y_pred, dtrain, alpha, gamma):
  2. a,g = alpha, gamma
  3. y_true = dtrain.label
  4. p = 1/(1+np.exp(-y_pred))
  5. loss = -( a*y_true + (1-a)*(1-y_true) ) * (( 1 - ( y_true*p + (1-y_true)*(1-p)) )**g) * ( y_true*np.log(p)+(1-y_true)*np.log(1-p) )
  6. # (eval_name, eval_result, is_higher_better)
  7. return 'focal_loss', np.mean(loss), False
RAW Paste Data