libcity.evaluator.eval_funcs¶
-
libcity.evaluator.eval_funcs.
top_k
(loc_pred, loc_true, topk)[source]¶ count the hit numbers of loc_true in topK of loc_pred, used to calculate Precision, Recall and F1-score, calculate the reciprocal rank, used to calcualte MRR, calculate the sum of DCG@K of the batch, used to calculate NDCG
- Parameters
loc_pred – (batch_size * output_dim)
loc_true – (batch_size * 1)
topk –
- Returns
- tuple contains:
hit (int): the hit numbers
rank (float): the sum of the reciprocal rank of input batch
dcg (float): dcg
- Return type
tuple