class_docstr: Implementation of Sparseness metric by Chalasani et al., 2020.
  
  Sparseness is quantified using the Gini Index applied to the vector of the absolute values of attributions. The
  test asks that features that are truly predictive of the output F(x) should have significant contributions, and
  similarly, that irrelevant (or weakly-relevant) features should have negligible contributions.
  
  Assumptions:
      - Based on the implementation of the authors as found on the following link:
      <https://github.com/jfc43/advex/blob/master/DNN-Experiments/Fashion-MNIST/utils.py>.
  
  References:
      1) Prasad Chalasani et al.: "Concise explanations of neural networks using adversarial training."
      International Conference on Machine Learning. PMLR, 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
  ----------
  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.
  softmax: boolean
      Indicates whether to use softmax probabilities or logits in model prediction, default=False.
  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.
      softmax: boolean
          Indicates whether to use softmax probabilities or logits in model prediction, default=False.
      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=(
                  "Chalasani, Prasad, et al. Concise explanations of neural networks using "
                  "adversarial training.' International Conference on Machine Learning. PMLR, "
                  "(2020)"
              ),
          )
  
file_path: Quantus/quantus/metrics/complexity/sparseness.py
imports: import sys
  from typing import Any, Callable, Dict, List, Optional
  import numpy
  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 Sparseness object from inherited base classes: Metric with example: obj = Sparseness(abs, normalise, normalise_func, normalise_func_kwargs, return_aggregate, aggregate_func, default_plot_func, disable_warnings, display_progressbar)