class_docstr: Implementation of ROAD evaluation strategy by Rong et al., 2022.
  
  The ROAD approach measures the accuracy of the model on the provided test set at each step of an iterative process
  of removing k most important pixels. At each step k most relevant pixels (MoRF order) are replaced with noisy linear
  imputations which removes bias.
  
  Assumptions:
      - The original metric definition relies on perturbation functionality suited only for images.
      Therefore, only apply the metric to 3-dimensional (image) data. To extend the applicablity
      to other data domains, adjustments to the current implementation might be necessary.
  
  References:
      1) Leemann Rong et al.: "Evaluating Feature Attribution: An Information-Theoretic Perspective." arXiv preprint
      arXiv:2202.00449 (2022).
  
  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","ROAD","evaluation","strategy","by","Rong","et","al.",",","2022",".","The","ROAD","approach","measures","the","accuracy","of","the","model","on","the","provided","test","set","at","each","step","of","an","iterative","process","of","removing","k","most","important","pixels",".","At","each","step","k","most","relevant","pixels","(","MoRF","order",")","are","replaced","with","noisy","linear","imputations","which","removes","bias",".","Assumptions",":","-","The","original","metric","definition","relies","on","perturbation","functionality","suited","only","for","images",".","Therefore",",","only","apply","the","metric","to","3-dimensional","(","image",")","data",".","To","extend","the","applicablity","to","other","data","domains",",","adjustments","to","the","current","implementation","might","be","necessary",".","References",":","1",")","Leemann","Rong","et","al",".",":","``","Evaluating","Feature","Attribution",":","An","Information-Theoretic","Perspective",".","''","arXiv","preprint","arXiv:2202.00449","(","2022",")",".","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
  ----------
  percentages (list): The list of percentages of the image to be removed, default=list(range(1, 100, 2)).
      noise (noise): Noise added, default=0.01.
  abs: boolean
      Indicates whether absolute operation is applied on the attribution, default=False.
  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_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","--","--","--","--","--","percentages","(","list",")",":","The","list","of","percentages","of","the","image","to","be","removed",",","default=list","(","range","(","1",",","100",",","2",")",")",".","noise","(","noise",")",":","Noise","added",",","default=0.01",".","abs",":","boolean","Indicates","whether","absolute","operation","is","applied","on","the","attribution",",","default=False",".","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_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,
      percentages: Optional[List[float]] = None,
      noise: float = 0.01,
      abs: bool = False,
      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_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
      ----------
      percentages (list): The list of percentages of the image to be removed, default=list(range(1, 100, 2)).
          noise (noise): Noise added, default=0.01.
      abs: boolean
          Indicates whether absolute operation is applied on the attribution, default=False.
      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_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 percentages is None:
          percentages = list(range(1, 100, 2))
  
      if perturb_func is None:
          perturb_func = noisy_linear_imputation
  
      self.percentages = percentages
      self.a_size = None
      self.perturb_func = make_perturb_func(
          perturb_func, perturb_func_kwargs, noise=noise
      )
  
      # Asserts and warnings.
      if not self.disable_warnings:
          warn.warn_parameterisation(
              metric_name=self.__class__.__name__,
              sensitive_params="perturbation function 'perturb_func'",
              data_domain_applicability=(
                  f"Also, the current implementation only works for 3-dimensional (image) data."
              ),
              citation=(
                  "Rong, Leemann, et al. 'Evaluating Feature Attribution: An Information-Theoretic Perspective.' "
                  "arXiv:2202.00449 (2022)"
              ),
          )
  
file_path: Quantus/quantus/metrics/faithfulness/road.py
imports: import sys
  from typing import Any, Callable, Dict, List, Optional
  import numpy
  from quantus.functions.perturb_func import noisy_linear_imputation
  from quantus.helpers import 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 ROAD object from inherited base classes: Metric with example: obj = ROAD(percentages, noise, abs, normalise, normalise_func, normalise_func_kwargs, perturb_func, perturb_func_kwargs, return_aggregate, aggregate_func, default_plot_func, disable_warnings, display_progressbar)