This file contains hidden or 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
| import numpy as np | |
| def dcg_at_k(r, k, method=0): | |
| """Score is discounted cumulative gain (dcg) | |
| Relevance is positive real values. Can use binary | |
| as the previous methods. | |
| Args: | |
| r: Relevance scores (list or numpy) in rank order |