rank_score¶
- ampligraph.evaluation.rank_score(y_true, y_pred, pos_lab=1)¶
Computes the rank of a triple.
The rank of a positive element against a list of negatives.
\[rank_{(s, p, o)_i}\]- Parameters:
y_true (ndarray, shape (n)) – An array of binary labels. The array only contains one positive.
y_pred (ndarray, shape (n)) – An array of scores, for the positive element and the n-1 negatives.
pos_lab (int) – The value of the positive label (default = 1).
- Returns:
rank – The rank of the positive element against the negatives.
- Return type:
int
Example
>>> import numpy as np >>> from ampligraph.evaluation.metrics import rank_score >>> y_pred = np.array([.434, .65, .21, .84]) >>> y_true = np.array([0, 0, 1, 0]) >>> rank_score(y_true, y_pred) 4