class_docstr: Implementation of the Consistency metric which measures the expected local consistency, i.e., the probability
  of the prediction label for a given datapoint coinciding with the prediction labels of other data points that
  the same explanation is being attributed to. For example, if the explanation of a given image is "contains zebra",
  the local consistency metric measures the probability a different image that the explanation "contains zebra" is
  being attributed to having the same prediction label.
  
  Assumptions:
      - A used-defined discreization function is used to discretize continuous explanation spaces.
  
  References:
       1) Sanjoy Dasgupta et al.: "Framework for Evaluating Faithfulness of Local
          Explanations." ICML (2022): 4794-4815.
  
  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","the","Consistency","metric","which","measures","the","expected","local","consistency",",","i.e.",",","the","probability","of","the","prediction","label","for","a","given","datapoint","coinciding","with","the","prediction","labels","of","other","data","points","that","the","same","explanation","is","being","attributed","to",".","For","example",",","if","the","explanation","of","a","given","image","is","``","contains","zebra","''",",","the","local","consistency","metric","measures","the","probability","a","different","image","that","the","explanation","``","contains","zebra","''","is","being","attributed","to","having","the","same","prediction","label",".","Assumptions",":","-","A","used-defined","discreization","function","is","used","to","discretize","continuous","explanation","spaces",".","References",":","1",")","Sanjoy","Dasgupta","et","al",".",":","``","Framework","for","Evaluating","Faithfulness","of","Local","Explanations",".","''","ICML","(","2022",")",":","4794-4815",".","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
  ----------
  discretise_func: callable
      Discretisation function applied to explantions.
      If None, the default value is used, default=top_n_sign.
  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={}.
  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","--","--","--","--","--","discretise_func",":","callable","Discretisation","function","applied","to","explantions",".","If","None",",","the","default","value","is","used",",","default=top_n_sign",".","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=","{","}",".","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,
      discretise_func: Optional[Callable] = None,
      abs: bool = True,
      normalise: bool = True,
      normalise_func: Optional[
          Callable[[np.ndarray], np.ndarray]
      ] = None,
      normalise_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
      ----------
      discretise_func: callable
          Discretisation function applied to explantions.
          If None, the default value is used, default=top_n_sign.
      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={}.
      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 discretise_func is None:
          discretise_func = top_n_sign
      self.discretise_func = discretise_func
      self.y_pred_classes = None
  
      # Asserts and warnings.
      if not self.disable_warnings:
          warn.warn_parameterisation(
              metric_name=self.__class__.__name__,
              sensitive_params=(
                  "Function for discretisation of the explanation space 'discretise_func' (return hash value of"
                  "an np.array used for comparison)."
              ),
              citation=(
                  "Sanjoy Dasgupta, Nave Frost, and Michal Moshkovitz. 'Framework for Evaluating Faithfulness of "
                  "Explanations.' arXiv preprint arXiv:2202.00734 (2022)"
              ),
          )
  
file_path: Quantus/quantus/metrics/robustness/consistency.py
imports: import sys
  from typing import Any, Callable, Dict, List, Optional, no_type_check
  import numpy
  from quantus.functions.discretise_func import top_n_sign
  from quantus.helpers.model.model_interface import ModelInterface
  from quantus.helpers import warn
  from quantus.helpers.enums import DataType, EvaluationCategory, ModelType, ScoreDirection
  from quantus.metrics.base import Metric
label_desc: Use image node_id 1 to create a new Consistency object from inherited base classes: Metric with example: obj = Consistency(discretise_func, abs, normalise, normalise_func, normalise_func_kwargs, return_aggregate, aggregate_func, default_plot_func, disable_warnings, display_progressbar)