Skip to content

Commit

Permalink
Merge pull request #41 from whongyi/master
Browse files Browse the repository at this point in the history
bug fix in eval_manager to support multiple pos_samples in evaluation…
  • Loading branch information
ylongqi committed Jan 11, 2019
2 parents ad4c196 + b15e094 commit 76cf66b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions openrec/utils/evaluators/eval_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(self, evaluators=[]):

def _full_rank(self, pos_samples, excl_pos_samples, predictions):


pos_samples_set = set(pos_samples)
pos_samples = np.array(pos_samples, dtype=np.int32)
pos_predictions = predictions[pos_samples]

Expand All @@ -17,12 +17,12 @@ def _full_rank(self, pos_samples, excl_pos_samples, predictions):

pos_samples_len = len(pos_samples)
for ind in range(len(predictions)):
if ind not in excl_pos_samples_set:
if ind not in excl_pos_samples_set and ind not in pos_samples_set:
for pos_ind in range(pos_samples_len):
if pos_predictions[pos_ind] < predictions[ind]:
rank_above[pos_ind] += 1

return rank_above, len(predictions) - len(excl_pos_samples)
return rank_above, len(predictions) - len(excl_pos_samples) - len(pos_samples)

def _partial_rank(self, pos_scores, neg_scores):

Expand Down Expand Up @@ -55,4 +55,4 @@ def partial_eval(self, pos_scores, neg_scores):
if evaluator.etype == 'rank':
results[evaluator.name] = evaluator.compute(rank_above=rank_above, negative_num=negative_num)

return results
return results

0 comments on commit 76cf66b

Please sign in to comment.