Skip to content

Instantly share code, notes, and snippets.

View cle-ment's full-sized avatar

Clemens Westrup cle-ment

View GitHub Profile
@cle-ment
cle-ment / duolingo_pred.ipynb
Created May 11, 2018 20:54
duolingo_pred.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 March 16, 2017 06:41
Find index of combination over arrays
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.