mapk shouldn't require actual and predicted have the same length
mvonpohle opened this issue · 2 comments
This assertion check is incorrect. The actual parameter as used in _apk is expecting a list of true items and the predicted parameter is expecting a list of predicted items that can be true or false. See an example below where only A-C are true items and the prediction can be longer than the true list because it can contain false items.
recmetrics/recmetrics/metrics.py
Lines 236 to 237 in b21222d
true_items = ["A","B","C"]
prediction = ["A","Z","B","X"]
metrics.mapk(actual=true_items, predicted=prediction, k = 3)
Looks like you should be using _apk? For average precision, they can be of different length so there is no assertion
recmetrics/recmetrics/metrics.py
Line 163 in b21222d
The mapk is expecting both ground truth and predictions to be list of list.
recmetrics/recmetrics/metrics.py
Line 220 in b21222d
Ahh, yes. You're right, my bad.