8d4fee5d7dc69f82aadb38abc4564dda5cc8580f,rankeval/core/metrics/dcg.py,DCG,eval_per_query,#DCG#Any#Any#,70

Before Change


            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


    def __str__(self):

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):
Italian Trulli
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: ultralytics/yolov3
Commit Name: 14e451962036515076b17b5bc01e89282f62b681
Time: 2019-04-21
Author: glenn.jocher@ultralytics.com
File Name: models.py
Class Name:
Method Name: create_grids


Project Name: idaholab/raven
Commit Name: 438b2a63d195c8f5ccecae35d577d8bfde354406
Time: 2020-08-22
Author: mohammad.abdo@inl.gov
File Name: framework/Optimizers/GeneticAlgorithm.py
Class Name: GeneticAlgorithm
Method Name: _useRealization