class_docstr: Implementation of Monotonicity Correlation metric by Nguyen at el., 2020.
  
  Monotonicity measures the (Spearman’s) correlation coefficient of the absolute values of the attributions
  and the uncertainty in probability estimation. The paper argues that if attributions are not monotonic
  then they are not providing the correct importance of the feature.
  
  References:
      1) An-phi Nguyen and María Rodríguez Martínez.: "On quantitative aspects of model
      interpretability." arXiv preprint arXiv:2007.07584 (2020).
  
  Attributes:
      -  _name: The name of the metric.
      - _data_applicability: The data types that the metric implementation currently supports.
      - _models: The model types that this metric can work with.
      - score_direction: How to interpret the scores, whether higher/ lower values are considered better.
      - evaluation_category: What property/ explanation quality that this metric measures.
class_docstr_tok: ["Implementation","of","Monotonicity","Correlation","metric","by","Nguyen","at","el.",",","2020",".","Monotonicity","measures","the","(","Spearman","\u2019","s",")","correlation","coefficient","of","the","absolute","values","of","the","attributions","and","the","uncertainty","in","probability","estimation",".","The","paper","argues","that","if","attributions","are","not","monotonic","then","they","are","not","providing","the","correct","importance","of","the","feature",".","References",":","1",")","An-phi","Nguyen","and","Mar\u00eda","Rodr\u00edguez","Mart\u00ednez",".",":","``","On","quantitative","aspects","of","model","interpretability",".","''","arXiv","preprint","arXiv:2007.07584","(","2020",")",".","Attributes",":","-","_name",":","The","name","of","the","metric",".","-","_data_applicability",":","The","data","types","that","the","metric","implementation","currently","supports",".","-","_models",":","The","model","types","that","this","metric","can","work","with",".","-","score_direction",":","How","to","interpret","the","scores",",","whether","higher\/","lower","values","are","considered","better",".","-","evaluation_category",":","What","property\/","explanation","quality","that","this","metric","measures","."]
docstr: Parameters
  ----------
  similarity_func: callable
      Similarity function applied to compare input and perturbed input.
      If None, the default value is used, default=correlation_spearman.
  eps: float
      Attributions threshold, default=1e-5.
  nr_samples: integer
      The number of samples to iterate over, default=100.
  features_in_step: integer
      The size of the step, default=1.
  abs: boolean
      Indicates whether absolute operation is applied on the attribution, default=True.
  normalise: boolean
      Indicates whether normalise operation is applied on the attribution, default=True.
  normalise_func: callable
      Attribution normalisation function applied in case normalise=True.
      If normalise_func=None, the default value is used, default=normalise_by_max.
  normalise_func_kwargs: dict
      Keyword arguments to be passed to normalise_func on call, default={}.
  perturb_func: callable
      Input perturbation function. If None, the default value is used,
      default=baseline_replacement_by_indices.
  perturb_baseline: string
      Indicates the type of baseline: "mean", "random", "uniform", "black" or "white",
      default="uniform".
  perturb_func_kwargs: dict
      Keyword arguments to be passed to perturb_func, default={}.
  return_aggregate: boolean
      Indicates if an aggregated score should be computed over all instances.
  aggregate_func: callable
      Callable that aggregates the scores given an evaluation call.
  default_plot_func: callable
      Callable that plots the metrics result.
  disable_warnings: boolean
      Indicates whether the warnings are printed, default=False.
  display_progressbar: boolean
      Indicates whether a tqdm-progress-bar is printed, default=False.
  kwargs: optional
      Keyword arguments.
docstr_tok: ["Parameters","--","--","--","--","--","similarity_func",":","callable","Similarity","function","applied","to","compare","input","and","perturbed","input",".","If","None",",","the","default","value","is","used",",","default=correlation_spearman",".","eps",":","float","Attributions","threshold",",","default=1e-5",".","nr_samples",":","integer","The","number","of","samples","to","iterate","over",",","default=100",".","features_in_step",":","integer","The","size","of","the","step",",","default=1",".","abs",":","boolean","Indicates","whether","absolute","operation","is","applied","on","the","attribution",",","default=True",".","normalise",":","boolean","Indicates","whether","normalise","operation","is","applied","on","the","attribution",",","default=True",".","normalise_func",":","callable","Attribution","normalisation","function","applied","in","case","normalise=True",".","If","normalise_func=None",",","the","default","value","is","used",",","default=normalise_by_max",".","normalise_func_kwargs",":","dict","Keyword","arguments","to","be","passed","to","normalise_func","on","call",",","default=","{","}",".","perturb_func",":","callable","Input","perturbation","function",".","If","None",",","the","default","value","is","used",",","default=baseline_replacement_by_indices",".","perturb_baseline",":","string","Indicates","the","type","of","baseline",":","``","mean","''",",","``","random","''",",","``","uniform","''",",","``","black","''","or","``","white","''",",","default=","''","uniform","''",".","perturb_func_kwargs",":","dict","Keyword","arguments","to","be","passed","to","perturb_func",",","default=","{","}",".","return_aggregate",":","boolean","Indicates","if","an","aggregated","score","should","be","computed","over","all","instances",".","aggregate_func",":","callable","Callable","that","aggregates","the","scores","given","an","evaluation","call",".","default_plot_func",":","callable","Callable","that","plots","the","metrics","result",".","disable_warnings",":","boolean","Indicates","whether","the","warnings","are","printed",",","default=False",".","display_progressbar",":","boolean","Indicates","whether","a","tqdm-progress-bar","is","printed",",","default=False",".","kwargs",":","optional","Keyword","arguments","."]
code: def __init__(
      self,
      similarity_func: Optional[Callable] = None,
      eps: float = 1e-5,
      nr_samples: int = 100,
      features_in_step: int = 1,
      abs: bool = True,
      normalise: bool = True,
      normalise_func: Optional[
          Callable[[np.ndarray], np.ndarray]
      ] = None,
      normalise_func_kwargs: Optional[Dict[str, Any]] = None,
      perturb_func: Optional[Callable] = None,
      perturb_baseline: str = "uniform",
      perturb_func_kwargs: Optional[Dict[str, Any]] = None,
      return_aggregate: bool = False,
      aggregate_func: Optional[Callable] = None,
      default_plot_func: Optional[Callable] = None,
      disable_warnings: bool = False,
      display_progressbar: bool = False,
      **kwargs,
  ):
      """
      Parameters
      ----------
      similarity_func: callable
          Similarity function applied to compare input and perturbed input.
          If None, the default value is used, default=correlation_spearman.
      eps: float
          Attributions threshold, default=1e-5.
      nr_samples: integer
          The number of samples to iterate over, default=100.
      features_in_step: integer
          The size of the step, default=1.
      abs: boolean
          Indicates whether absolute operation is applied on the attribution, default=True.
      normalise: boolean
          Indicates whether normalise operation is applied on the attribution, default=True.
      normalise_func: callable
          Attribution normalisation function applied in case normalise=True.
          If normalise_func=None, the default value is used, default=normalise_by_max.
      normalise_func_kwargs: dict
          Keyword arguments to be passed to normalise_func on call, default={}.
      perturb_func: callable
          Input perturbation function. If None, the default value is used,
          default=baseline_replacement_by_indices.
      perturb_baseline: string
          Indicates the type of baseline: "mean", "random", "uniform", "black" or "white",
          default="uniform".
      perturb_func_kwargs: dict
          Keyword arguments to be passed to perturb_func, default={}.
      return_aggregate: boolean
          Indicates if an aggregated score should be computed over all instances.
      aggregate_func: callable
          Callable that aggregates the scores given an evaluation call.
      default_plot_func: callable
          Callable that plots the metrics result.
      disable_warnings: boolean
          Indicates whether the warnings are printed, default=False.
      display_progressbar: boolean
          Indicates whether a tqdm-progress-bar is printed, default=False.
      kwargs: optional
          Keyword arguments.
      """
      super().__init__(
          abs=abs,
          normalise=normalise,
          normalise_func=normalise_func,
          normalise_func_kwargs=normalise_func_kwargs,
          return_aggregate=return_aggregate,
          aggregate_func=aggregate_func,
          default_plot_func=default_plot_func,
          display_progressbar=display_progressbar,
          disable_warnings=disable_warnings,
          **kwargs,
      )
  
      # Save metric-specific attributes.
      if similarity_func is None:
          similarity_func = correlation_spearman
  
      if perturb_func is None:
          perturb_func = baseline_replacement_by_indices
  
      self.similarity_func = similarity_func
  
      self.eps = eps
      self.nr_samples = nr_samples
      self.features_in_step = features_in_step
      self.perturb_func = make_perturb_func(
          perturb_func,
          perturb_func_kwargs,
          perturb_baseline=perturb_baseline,
      )
  
      # Asserts and warnings.
      if not self.disable_warnings:
          warn.warn_parameterisation(
              metric_name=self.__class__.__name__,
              sensitive_params=(
                  "baseline value 'perturb_baseline', threshold value 'eps' and number "
                  "of samples to iterate over 'nr_samples'"
              ),
              citation=(
                  "Nguyen, An-phi, and María Rodríguez Martínez. 'On quantitative aspects of "
                  "model interpretability.' arXiv preprint arXiv:2007.07584 (2020)"
              ),
          )
  
file_path: Quantus/quantus/metrics/faithfulness/monotonicity_correlation.py
imports: import sys
  from typing import Any, Callable, Dict, List, Optional
  import numpy
  from quantus.functions.perturb_func import baseline_replacement_by_indices
  from quantus.functions.similarity_func import correlation_spearman
  from quantus.helpers import asserts, warn
  from quantus.helpers.enums import DataType, EvaluationCategory, ModelType, ScoreDirection
  from quantus.helpers.model.model_interface import ModelInterface
  from quantus.helpers.perturbation_utils import make_perturb_func
  from quantus.metrics.base import Metric
label_desc: Use image node_id 1 to create a new MonotonicityCorrelation object from inherited base classes: Metric with example: obj = MonotonicityCorrelation(similarity_func, eps, nr_samples, features_in_step, abs, normalise, normalise_func, normalise_func_kwargs, perturb_func, perturb_baseline, perturb_func_kwargs, return_aggregate, aggregate_func, default_plot_func, disable_warnings, display_progressbar)