Package org.opensearch.index.rankeval
Class RecallAtK
java.lang.Object
org.opensearch.index.rankeval.RecallAtK
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,ToXContentObject,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 ClassesNested classes/interfaces inherited from interface org.opensearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.opensearch.common.io.stream.Writeable
Writeable.Reader<V extends Object>, Writeable.Writer<V extends Object> -
Field Summary
FieldsFields inherited from interface org.opensearch.common.xcontent.ToXContent
EMPTY_PARAMS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanevaluate(String taskId, SearchHit[] hits, List<RatedDocument> ratedDocs) Compute recall at k based on provided relevant document IDs.Metrics can define a size of the search hits windows they want to retrieve by overwriting this method.static RecallAtKfromXContent(XContentParser parser) intgetK()intReturn the rating threshold above which ratings are considered to be "relevant" for this metric.final inthashCode()toXContent(XContentBuilder builder, ToXContent.Params params) voidwriteTo(StreamOutput out) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opensearch.index.rankeval.EvaluationMetric
combineMethods inherited from interface org.opensearch.common.xcontent.ToXContentObject
isFragment
-
Field Details
-
NAME
- See Also:
-
-
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
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
getWriteableName
- Specified by:
getWriteableNamein interfaceNamedWriteable
-
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
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
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
-
hashCode
public final int hashCode()
-