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 tofalse
by 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 class
DiscountedCumulativeGain.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.String
NAME
-
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 boolean
equals(java.lang.Object obj)
EvalQueryQuality
evaluate(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 DiscountedCumulativeGain
fromXContent(XContentParser parser)
java.lang.Integer
getUnknownDocRating()
get the rating used for unrated documentsjava.lang.String
getWriteableName()
int
hashCode()
XContentBuilder
toXContent(XContentBuilder builder, ToXContent.Params params)
void
writeTo(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:
getWriteableName
in 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: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, 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 DiscountedCumulativeGain fromXContent(XContentParser parser)
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
toXContent
in interfaceToXContent
- 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
-
-