Package org.elasticsearch.index.rankeval
Class DiscountedCumulativeGain
java.lang.Object
org.elasticsearch.index.rankeval.DiscountedCumulativeGain
- All Implemented Interfaces:
org.elasticsearch.common.io.stream.NamedWriteable,org.elasticsearch.common.io.stream.Writeable,EvaluationMetric,org.elasticsearch.xcontent.ToXContent,org.elasticsearch.xcontent.ToXContentObject
Metric implementing Discounted Cumulative Gain.
The `normalize` parameter can be set to calculate the normalized NDCG (set to
The optional `unknown_doc_rating` parameter can be used to specify a default rating for unlabeled documents.
false by default).The optional `unknown_doc_rating` parameter can be used to specify a default rating for unlabeled documents.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
org.elasticsearch.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.xcontent.ToXContent.MapParams, org.elasticsearch.xcontent.ToXContent.Params -
Field Summary
FieldsFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionDiscountedCumulativeGain(boolean normalize, Integer unknownDocRating, int k) -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanevaluate(String taskId, org.elasticsearch.search.SearchHit[] hits, List<RatedDocument> ratedDocs) Evaluates a single ranking evaluation case.Metrics can define a size of the search hits windows they want to retrieve by overwriting this method.static DiscountedCumulativeGainfromXContent(org.elasticsearch.xcontent.XContentParser parser) get the rating used for unrated documentsfinal inthashCode()org.elasticsearch.xcontent.XContentBuildertoXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.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.xcontent.ToXContentObject
isFragment
-
Field Details
-
NAME
- See Also:
-
-
Constructor Details
-
DiscountedCumulativeGain
public DiscountedCumulativeGain() -
DiscountedCumulativeGain
- 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 Details
-
writeTo
- Specified by:
writeToin interfaceorg.elasticsearch.common.io.stream.Writeable- Throws:
IOException
-
getWriteableName
- Specified by:
getWriteableNamein interfaceorg.elasticsearch.common.io.stream.NamedWriteable
-
getUnknownDocRating
get the rating used for unrated documents -
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(String taskId, org.elasticsearch.search.SearchHit[] hits, 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(org.elasticsearch.xcontent.XContentParser parser) -
toXContent
public org.elasticsearch.xcontent.XContentBuilder toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceorg.elasticsearch.xcontent.ToXContent- Throws:
IOException
-
equals
-
hashCode
public final int hashCode()
-