c672738b39c8f739551da0d88991a2fedfba3e14,deeppavlov/models/ranking/metrics.py,,rank_response,#Any#Any#,37

Before Change


    labels = np.array(y_true)
    predictions = np.array(y_pred)
    predictions = np.argsort(predictions, -1)
    ranks = []
    for i in range(predictions.shape[0]):
        for j in range(predictions.shape[1]):
            if predictions[i][j] in np.arange(labels[i][j]):
                ranks.append(j)
                break
    return np.mean(np.asarray(ranks).astype(float))


@register_metric("loss")

After Change


    predictions = np.flip(np.argsort(predictions, -1), -1)
    rank_tot = 0
    for el in predictions:
        for i, x in enumerate(el):
            if x == 0:
                rank_tot += i
                break
    return float(rank_tot)/num_examples

@register_metric("r@1_insQA")
def r_at_1_insQA(y_true, y_pred):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

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: rank_response


Project Name: BVLC/caffe
Commit Name: 0db94786a7a463fed49825811fac903f1f1fc3c8
Time: 2014-08-05
Author: shelhamer@imaginarynumber.net
File Name: python/caffe/classifier.py
Class Name: Classifier
Method Name: predict


Project Name: deepchem/deepchem
Commit Name: c96af58e6ab2f85626e51a331e8479da49329f0e
Time: 2017-01-18
Author: joegomes@stanford.edu
File Name: deepchem/models/tensorflow_models/__init__.py
Class Name: TensorflowClassifier
Method Name: predict_proba_on_batch