kiez.evaluate.eval_metrics¶
Calculate evaluation metrics such as hits@k.
Functions
|
Show hits@k. |
- kiez.evaluate.eval_metrics.hits(nn_ind: Union[ndarray, Dict[Any, List]], gold: Dict[Any, Any], k=None) Dict[int, float] [source]¶
Show hits@k.
- Parameters:
nn_ind (array or dict) – Contains the indices of the nearest neighbors for source entities.
gold (dict) – Map of source indices to the respective target indices
k (array) – Which ks should be evaluated
- Returns:
hits – k: relative hits@k values
- Return type:
dict
Examples
>>> from kiez.evaluate import hits >>> import numpy as np >>> nn_ind = np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) >>> gold = {0: 2, 1: 4, 2: 3, 3: 4} >>> hits(nn_ind, gold) {1: 0.5, 5: 1.0, 10: 1.0}