Package org.elasticsearch.index.rankeval
Class ExpectedReciprocalRank
- java.lang.Object
-
- org.elasticsearch.index.rankeval.ExpectedReciprocalRank
-
- All Implemented Interfaces:
org.elasticsearch.common.io.stream.NamedWriteable
,org.elasticsearch.common.io.stream.Writeable
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentObject
,EvaluationMetric
public class ExpectedReciprocalRank extends java.lang.Object implements EvaluationMetric
Implementation of the Expected Reciprocal Rank metric described in:Chapelle, O., Metlzer, D., Zhang, Y., & Grinspan, P. (2009).
Expected reciprocal rank for graded relevance.
Proceeding of the 18th ACM Conference on Information and Knowledge Management - CIKM ’09, 621.
https://doi.org/10.1145/1645953.1646033
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ExpectedReciprocalRank.Detail
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
NAME
-
Constructor Summary
Constructors Constructor Description ExpectedReciprocalRank(int maxRelevance)
ExpectedReciprocalRank(int maxRelevance, java.lang.Integer unknownDocRating, int k)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
EvalQueryQuality
evaluate(java.lang.String taskId, org.elasticsearch.search.SearchHit[] hits, java.util.List<RatedDocument> ratedDocs)
Evaluates a single ranking evaluation case.java.util.Optional<java.lang.Integer>
forcedSearchSize()
Metrics can define a size of the search hits windows they want to retrieve by overwriting this method.static ExpectedReciprocalRank
fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
java.lang.Integer
getUnknownDocRating()
get the rating used for unrated documentsjava.lang.String
getWriteableName()
int
hashCode()
org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
void
writeTo(org.elasticsearch.common.io.stream.StreamOutput out)
-
Methods inherited from interface org.elasticsearch.index.rankeval.EvaluationMetric
combine
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ExpectedReciprocalRank
public ExpectedReciprocalRank(int maxRelevance)
- Parameters:
maxRelevance
- the highest expected relevance in the data
-
ExpectedReciprocalRank
public ExpectedReciprocalRank(int maxRelevance, @Nullable java.lang.Integer unknownDocRating, int k)
- Parameters:
maxRelevance
- the maximal relevance judgment in the evaluation datasetunknownDocRating
- the rating for documents the user hasn't supplied an explicit rating for. Can benull
, in which case document is skipped.k
- the search window size all request use.
-
-
Method Detail
-
writeTo
public void writeTo(org.elasticsearch.common.io.stream.StreamOutput out) throws java.io.IOException
- Specified by:
writeTo
in interfaceorg.elasticsearch.common.io.stream.Writeable
- Throws:
java.io.IOException
-
getWriteableName
public java.lang.String getWriteableName()
- Specified by:
getWriteableName
in interfaceorg.elasticsearch.common.io.stream.NamedWriteable
-
getUnknownDocRating
public java.lang.Integer getUnknownDocRating()
get the rating used for unrated documents
-
forcedSearchSize
public java.util.Optional<java.lang.Integer> 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 interfaceEvaluationMetric
- Returns:
- the number of search hits this metrics requests
-
evaluate
public EvalQueryQuality evaluate(java.lang.String taskId, org.elasticsearch.search.SearchHit[] hits, java.util.List<RatedDocument> ratedDocs)
Description copied from interface:EvaluationMetric
Evaluates a single ranking evaluation case.- Specified by:
evaluate
in interfaceEvaluationMetric
- Parameters:
taskId
- an identifier of the query for which the search ranking is evaluatedhits
- the search result hitsratedDocs
- 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
-
fromXContent
public static ExpectedReciprocalRank fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
- Specified by:
toXContent
in interfaceorg.elasticsearch.common.xcontent.ToXContent
- Throws:
java.io.IOException
-
equals
public final boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-