c672738b39c8f739551da0d88991a2fedfba3e14,deeppavlov/models/ranking/metrics.py,,recall_at_k,#Any#Any#Any#,24

Before Change


        for j in range(predictions.shape[1]):
            if predictions[i][j] in np.arange(labels[i][j]):
                flags[i][j] = 1.
    return np.mean((np.sum(flags, -1) >= 1.).astype(float))


@register_metric("rank_response")

After Change


    return recall_at_k(labels, predictions, k=10)

def recall_at_k(y_true, y_pred, k):
    num_examples = float(len(y_pred))
    predictions = np.array(y_pred)
    predictions = np.flip(np.argsort(predictions, -1), -1)[:, :k]
    num_correct = 0
    for el in predictions:
        if 0 in el:
            num_correct += 1
    return float(num_correct) / num_examples

@register_metric("rank_response")
def rank_response(y_true, y_pred):
    num_examples = float(len(y_pred))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: deepmipt/DeepPavlov
Commit Name: c672738b39c8f739551da0d88991a2fedfba3e14
Time: 2018-10-04
Author: puleon@mail.ru
File Name: deeppavlov/models/ranking/metrics.py
Class Name:
Method Name: recall_at_k


Project Name: deepmipt/DeepPavlov
Commit Name: c672738b39c8f739551da0d88991a2fedfba3e14
Time: 2018-10-04
Author: puleon@mail.ru
File Name: deeppavlov/models/ranking/metrics.py
Class Name:
Method Name: rank_response


Project Name: keras-team/keras
Commit Name: 42ccc34b337f9eb05de7f864a88844352740133a
Time: 2017-11-18
Author: ozabluda@gmail.com
File Name: examples/mnist_dataset_api.py
Class Name:
Method Name: