ADD Recall metrics#4
Conversation
| from .metric import Metric | ||
|
|
||
| class Recall(Metric): | ||
| def __init__(self, total_positive): |
There was a problem hiding this comment.
Better to take xrelnum as input for __init__ and compute the total_positive in __init__. This would enable the users to take the same actions for all kinds of metrics.
| self.total_positives = total_positive | ||
|
|
||
| def compute(self, labeled_ranked_list): | ||
| true_positives = sum(item[1] if item[1] is not None else 0 for item in labeled_ranked_list) |
There was a problem hiding this comment.
To clarify what item[1] is, better to write the for-loop as follows:
sum(grade if grade is not None else 0 for docid, grade in labeled_ranked_list)
In addition, grade can be 1 or larger (e.g., 2). Thus,
len(grade for docid, grade in labeled_ranked_list if grade is not None and grade > 0)
| assert total_positive == 3 | ||
|
|
||
| result = metric.compute(labeled_ranked_list) | ||
| assert result == 1.0 No newline at end of file |
There was a problem hiding this comment.
Please consider the case where recall is not 1.0. Recall=1.0 is a special case.
|
I've made the requested modifications to the Recall calculation based on your comments. |
|
Added comments to the recall function. Please review. |
Recallを計算するプログラムとそのテストを追加しました.
よろしくお願いします.