Package org.elasticsearch.index.rankeval
Class DiscountedCumulativeGain
- java.lang.Object
-
- org.elasticsearch.index.rankeval.DiscountedCumulativeGain
-
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,ToXContentObject,EvaluationMetric
public class DiscountedCumulativeGain extends java.lang.Object implements EvaluationMetric
Metric implementing Discounted Cumulative Gain. The `normalize` parameter can be set to calculate the normalized NDCG (set tofalseby default).
The optional `unknown_doc_rating` parameter can be used to specify a default rating for unlabeled documents.- See Also:
- Discounted Cumulative Gain
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDiscountedCumulativeGain.Detail-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V extends java.lang.Object>, Writeable.Writer<V extends java.lang.Object>
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringNAME-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Constructor Description DiscountedCumulativeGain()DiscountedCumulativeGain(boolean normalize, java.lang.Integer unknownDocRating, int k)
-
Method Summary
Modifier and Type Method Description booleanequals(java.lang.Object obj)EvalQueryQualityevaluate(java.lang.String taskId, 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 DiscountedCumulativeGainfromXContent(XContentParser parser)java.lang.IntegergetUnknownDocRating()get the rating used for unrated documentsjava.lang.StringgetWriteableName()inthashCode()XContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params)voidwriteTo(StreamOutput out)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.index.rankeval.EvaluationMetric
combine
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DiscountedCumulativeGain
public DiscountedCumulativeGain()
-
DiscountedCumulativeGain
public DiscountedCumulativeGain(boolean normalize, java.lang.Integer unknownDocRating, int k)- Parameters:
normalize- If set to true, dcg will be normalized (ndcg) See https://en.wikipedia.org/wiki/Discounted_cumulative_gainunknownDocRating- the rating for documents the user hasn't supplied an explicit rating fork- the search window size all request use.
-
-
Method Detail
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
-
getWriteableName
public java.lang.String getWriteableName()
- Specified by:
getWriteableNamein interfaceNamedWriteable
-
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: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, SearchHit[] hits, java.util.List<RatedDocument> ratedDocs)
Description copied from interface:EvaluationMetricEvaluates a single ranking evaluation case.- 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:
- an
EvalQueryQualityinstance that contains the metric score with respect to the provided search hits and ratings
-
fromXContent
public static DiscountedCumulativeGain fromXContent(XContentParser parser)
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
toXContentin interfaceToXContent- Throws:
java.io.IOException
-
equals
public final boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-