interpret_community.common.metrics module

Defines metrics for validating model explanations.

interpret_community.common.metrics.dcg(validate_order, ground_truth_order_relevance, top_values=10)

Compute the discounted cumulative gain (DCG).

Compute the DCG as the sum of relevance scores penalized by the logarithmic position of the result. See https://en.wikipedia.org/wiki/Discounted_cumulative_gain for reference.

Parameters:
  • validate_order (list) – The order to validate.

  • ground_truth_order_relevance (list) – The ground truth relevancy of the documents to compare to.

  • top_values (int) – Specifies the top values to compute the DCG for. The default is 10.

interpret_community.common.metrics.ndcg(validate_order, ground_truth_order, top_values=10)

Compute the normalized discounted cumulative gain (NDCG).

Compute the NDCG as the ratio of the DCG for the validation order compared to the maximum DCG possible for the ground truth order. If the validation order is the same as the ground truth the NDCG will be the maximum of 1.0, and the least possible NDCG is 0.0. See https://en.wikipedia.org/wiki/Discounted_cumulative_gain for reference.

Parameters:
  • validate_order (list) – The order to validate for the documents. The values should be unique.

  • ground_truth_order (list) – The true order of the documents. The values should be unique.

  • top_values (int) – Specifies the top values to compute the NDCG for. The default is 10.