Class MeanReciprocalRank

  • All Implemented Interfaces:
    NamedWriteable, Writeable, ToXContent, ToXContentObject, EvaluationMetric

    public class MeanReciprocalRank
    extends java.lang.Object
    implements EvaluationMetric
    Metric implementing Mean Reciprocal Rank (https://en.wikipedia.org/wiki/Mean_reciprocal_rank).
    By default documents with a rating equal or bigger than 1 are considered to be "relevant" for the reciprocal rank calculation. This value can be changes using the relevant_rating_threshold` parameter.
    • Constructor Detail

      • MeanReciprocalRank

        public MeanReciprocalRank()
      • MeanReciprocalRank

        public MeanReciprocalRank​(int relevantRatingThreshold,
                                  int k)
        Metric implementing Mean Reciprocal Rank (https://en.wikipedia.org/wiki/Mean_reciprocal_rank).
        Parameters:
        relevantRatingThreshold - the rating value that a document needs to be regarded as "relevant". Defaults to 1.
        k - the search window size all request use.
    • Method Detail

      • writeTo

        public void writeTo​(StreamOutput out)
                     throws java.io.IOException
        Specified by:
        writeTo in interface Writeable
        Throws:
        java.io.IOException
      • forcedSearchSize

        public java.util.OptionalInt forcedSearchSize()
        Description copied from interface: EvaluationMetric
        Metrics can define a size of the search hits windows they want to retrieve by overwriting this method. The default implementation returns an empty optional.
        Specified by:
        forcedSearchSize in interface EvaluationMetric
        Returns:
        the number of search hits this metrics requests
      • getRelevantRatingThreshold

        public int getRelevantRatingThreshold()
        Return the rating threshold above which ratings are considered to be "relevant".
      • evaluate

        public EvalQueryQuality evaluate​(java.lang.String taskId,
                                         SearchHit[] hits,
                                         java.util.List<RatedDocument> ratedDocs)
        Compute ReciprocalRank based on provided relevant document IDs.
        Specified by:
        evaluate in interface EvaluationMetric
        Parameters:
        taskId - an identifier of the query for which the search ranking is evaluated
        hits - the search result hits
        ratedDocs - the documents that contain the document rating for this query case
        Returns:
        an EvalQueryQuality instance that contains the metric score with respect to the provided search hits and ratings
      • equals

        public final boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class java.lang.Object