Created
January 23, 2017 19:59
-
-
Save sswt/d229aad3612c5144e2abd38bb7997062 to your computer and use it in GitHub Desktop.
Outbrain map@12 evaluation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def eval_map(yhat, dtrain): | |
inds = (-yhat).argsort(kind='mergesort') | |
X = np.vstack([dtrain.data['display_id'], dtrain.get_label()]).T | |
X = X[inds[X[inds, 0].argsort(kind='mergesort')]] | |
y_ind = np.where(X[:, 1] == 1)[0] | |
y_pr = np.unique(X[:, 0], return_index=True)[1] | |
return 'map@12_ob', np.mean(1 / (y_ind - y_pr + 1)), True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment