Skip to content

Instantly share code, notes, and snippets.

Avatar

Clemens Westrup cle-ment

View GitHub Profile
View duolingo_pred.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Normalized Discounted Cumulative Gain
def dcg(relevances, rank=10):
"""Discounted cumulative gain at rank (DCG)"""
relevances = np.asarray(relevances)[:rank]
n_relevances = len(relevances)
if n_relevances == 0:
return 0.
discounts = np.log2(np.arange(n_relevances) + 2)
return np.sum(relevances / discounts)
@cle-ment
cle-ment / find-index-of-combination-in-arrays.ipynb
Last active Mar 16, 2017
Find index of combination over arrays
View find-index-of-combination-in-arrays.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.