def measure(self, target: Labelling, predicted) -> float: avg_prec = 0.0 npos = target.positives() if (npos == 0): return 1.0 pos_idxs = target.where_positive() for i in pos_idxs: yi_rank = predicted[i] s = sum([1 for j in pos_idxs if predicted[j] <= yi_rank]) avg_prec += s / yi_rank return avg_prec / npos
def measure(self, target: Labelling, predicted) -> float: positives_idxs = target.where_positive() return sum([1 / predicted[pi] for pi in positives_idxs]) / sum( 1 / np.arange(1, target.positives() + 1))
def measure(self, target: Labelling, predicted) -> float: positives_idxs = target.where_positive() if (len(positives_idxs) == 0): return 0.0 return max([predicted[pi] for pi in positives_idxs ]) # / len(target) / target.positives()