Package org.elasticsearch.index.rankeval
Class RecallAtK
java.lang.Object
org.elasticsearch.index.rankeval.RecallAtK
- 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 RecallAtK extends java.lang.Object implements EvaluationMetric
Metric implementing Recall@K
(https://en.wikipedia.org/wiki/Evaluation_measures_(information_retrieval)#Recall).
By default documents with a rating equal or bigger than 1 are considered to be "relevant" for this calculation. This value can be changed using the `relevant_rating_threshold` parameter.
The `k` parameter (defaults to 10) controls the search window size.
By default documents with a rating equal or bigger than 1 are considered to be "relevant" for this calculation. This value can be changed using the `relevant_rating_threshold` parameter.
The `k` parameter (defaults to 10) controls the search window size.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRecallAtK.DetailNested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
org.elasticsearch.common.io.stream.Writeable.Reader<V extends java.lang.Object>, org.elasticsearch.common.io.stream.Writeable.Writer<V extends java.lang.Object> -
Field Summary
Fields Modifier and Type Field Description static java.lang.StringNAMEFields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS -
Constructor Summary
-
Method Summary
Modifier and Type Method Description booleanequals(java.lang.Object obj)EvalQueryQualityevaluate(java.lang.String taskId, org.elasticsearch.search.SearchHit[] hits, java.util.List<RatedDocument> ratedDocs)Compute recall at k based on provided relevant document IDs.java.util.OptionalIntforcedSearchSize()Metrics can define a size of the search hits windows they want to retrieve by overwriting this method.static RecallAtKfromXContent(org.elasticsearch.common.xcontent.XContentParser parser)intgetK()intgetRelevantRatingThreshold()Return the rating threshold above which ratings are considered to be "relevant" for this metric.java.lang.StringgetWriteableName()inthashCode()org.elasticsearch.common.xcontent.XContentBuildertoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)voidwriteTo(org.elasticsearch.common.io.stream.StreamOutput out)Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.index.rankeval.EvaluationMetric
combineMethods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
Field Details
-
NAME
public static final java.lang.String NAME- See Also:
- Constant Field Values
-
-
Constructor Details
-
RecallAtK
public RecallAtK(int relevantRatingThreshold, int k)Metric implementing Recall@K.- Parameters:
relevantRatingThreshold- ratings equal or above this value will be considered relevant.k- controls the window size for the search results the metric takes into account
-
RecallAtK
public RecallAtK()
-
-
Method Details
-
fromXContent
-
writeTo
public void writeTo(org.elasticsearch.common.io.stream.StreamOutput out) throws java.io.IOException- Specified by:
writeToin interfaceorg.elasticsearch.common.io.stream.Writeable- Throws:
java.io.IOException
-
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:
toXContentin interfaceorg.elasticsearch.common.xcontent.ToXContent- Throws:
java.io.IOException
-
getWriteableName
public java.lang.String getWriteableName()- Specified by:
getWriteableNamein interfaceorg.elasticsearch.common.io.stream.NamedWriteable
-
getRelevantRatingThreshold
public int getRelevantRatingThreshold()Return the rating threshold above which ratings are considered to be "relevant" for this metric. Defaults to 1. -
getK
public int getK() -
forcedSearchSize
public java.util.OptionalInt forcedSearchSize()Description copied from interface:EvaluationMetricMetrics 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:
forcedSearchSizein 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)Compute recall at k based on provided relevant document IDs.- Specified by:
evaluatein 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:
- recall at k for above
SearchResultlist.
-
equals
public final boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public final int hashCode()- Overrides:
hashCodein classjava.lang.Object
-