class_docstr: Implementation of Complexity metric by Bhatt et al., 2020.
  
  Complexity of attributions is defined as the entropy of the fractional contribution of feature x_i to the total
  magnitude of the attribution. A complex explanation is one that uses all features in its explanation to explain
  some decision. Even though such an explanation may be faithful to the model output, if the number of features is
  too large it may be too difficult for the user to understand the explanations, rendering it useless.
  
  References:
      1) Umang Bhatt et al.: "Evaluating and aggregating
      feature-based model explanations." IJCAI (2020): 3016-3022.
  
  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","Complexity","metric","by","Bhatt","et","al.",",","2020",".","Complexity","of","attributions","is","defined","as","the","entropy","of","the","fractional","contribution","of","feature","x_i","to","the","total","magnitude","of","the","attribution",".","A","complex","explanation","is","one","that","uses","all","features","in","its","explanation","to","explain","some","decision",".","Even","though","such","an","explanation","may","be","faithful","to","the","model","output",",","if","the","number","of","features","is","too","large","it","may","be","too","difficult","for","the","user","to","understand","the","explanations",",","rendering","it","useless",".","References",":","1",")","Umang","Bhatt","et","al",".",":","``","Evaluating","and","aggregating","feature-based","model","explanations",".","''","IJCAI","(","2020",")",":","3016-3022",".","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
  ----------
  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={}.
  default_plot_func: callable
      Callable that plots the metrics result.
  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.
  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","--","--","--","--","--","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=","{","}",".","default_plot_func",":","callable","Callable","that","plots","the","metrics","result",".","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",".","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,
      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
      ----------
      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={}.
      default_plot_func: callable
          Callable that plots the metrics result.
      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.
      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.
      """
      if not abs:
          warn.warn_absolute_operation()
  
      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,
      )
  
      # Asserts and warnings.
      if not self.disable_warnings:
          warn.warn_parameterisation(
              metric_name=self.__class__.__name__,
              sensitive_params=(
                  "normalising 'normalise' (and 'normalise_func') and if taking absolute"
                  " values of attributions 'abs'"
              ),
              citation=(
                  "Bhatt, Umang, Adrian Weller, and José MF Moura. 'Evaluating and aggregating"
                  " feature-based model explanations.' arXiv preprint arXiv:2005.00631 (2020)"
              ),
          )
  
file_path: Quantus/quantus/metrics/complexity/complexity.py
imports: import sys
  from typing import Any, Callable, Dict, List, Optional
  import numpy
  import scipy
  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 Complexity object from inherited base classes: Metric with example: obj = Complexity(abs, normalise, normalise_func, normalise_func_kwargs, return_aggregate, aggregate_func, default_plot_func, disable_warnings, display_progressbar)