Class: EvalRuby::Metrics::MRR
Overview
Computes Mean Reciprocal Rank: 1/(position of first relevant document).
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#call(retrieved:, relevant:, **_kwargs) ⇒ Float
Reciprocal rank (0.0-1.0).
Methods inherited from Base
Constructor Details
This class inherits a constructor from EvalRuby::Metrics::Base
Instance Method Details
#call(retrieved:, relevant:, **_kwargs) ⇒ Float
Returns reciprocal rank (0.0-1.0).
14 15 16 17 18 19 |
# File 'lib/eval_ruby/metrics/mrr.rb', line 14 def call(retrieved:, relevant:, **_kwargs) retrieved.each_with_index do |doc, i| return 1.0 / (i + 1) if relevant.include?(doc) end 0.0 end |