8d4fee5d7dc69f82aadb38abc4564dda5cc8580f,rankeval/core/metrics/dcg.py,DCG,eval_per_query,#DCG#Any#Any#,70
Before Change
idx_y_pred_sorted = idx_y_pred_sorted[:self.cutoff]
if self.implementation == "flat":
dcg = sum([y[rank] / (np.math.log(float(k) + 2.0, 2))
for k, rank in enumerate(idx_y_pred_sorted)])
elif self.implementation == "exp":
dcg = sum([(2.0 ** y[rank] - 1.0) / (np.math.log(float(k) + 2.0, 2))
for k, rank in enumerate(idx_y_pred_sorted)])
return dcg
After Change
if self.cutoff is not None:
idx_y_pred_sorted = idx_y_pred_sorted[:self.cutoff]
discount = np.log2(np.arange(2, len(idx_y_pred_sorted)+2))
if self.implementation == "flat":
gain = y[idx_y_pred_sorted]
elif self.implementation == "exp":
gain = np.exp2(y[idx_y_pred_sorted]) - 1.0
dcg = (gain / discount).sum()
return dcg
def __str__(self):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 6
Instances
Project Name: hpclab/rankeval
Commit Name: 8d4fee5d7dc69f82aadb38abc4564dda5cc8580f
Time: 2017-06-14
Author: cristina.i.muntean@gmail.com
File Name: rankeval/core/metrics/dcg.py
Class Name: DCG
Method Name: eval_per_query
Project Name: scipy/scipy
Commit Name: d8caeaaa2548c8da2501641d868b18184c7a41f3
Time: 2015-11-09
Author: andyfaff@gmail.com
File Name: benchmarks/benchmarks/go_benchmark_functions/go_funcs_P.py
Class Name: PermFunction01
Method Name: fun
Project Name: scipy/scipy
Commit Name: d8caeaaa2548c8da2501641d868b18184c7a41f3
Time: 2015-11-09
Author: andyfaff@gmail.com
File Name: benchmarks/benchmarks/go_benchmark_functions/go_funcs_P.py
Class Name: PermFunction02
Method Name: fun