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: Evaluate instance gets model and data for a single instance as input and returns the evaluation result.
  
  Parameters
  ----------
  model: ModelInterface
      A ModelInteface that is subject to explanation.
  x: np.ndarray
      The input to be evaluated on an instance-basis.
  y: np.ndarray
      The output to be evaluated on an instance-basis.
  a: np.ndarray
      The explanation to be evaluated on an instance-basis.
  
  Returns
  -------
  list:
      The evaluation results.
docstr_tok: ["Evaluate","instance","gets","model","and","data","for","a","single","instance","as","input","and","returns","the","evaluation","result",".","Parameters","--","--","--","--","--","model",":","ModelInterface","A","ModelInteface","that","is","subject","to","explanation",".","x",":","np.ndarray","The","input","to","be","evaluated","on","an","instance-basis",".","y",":","np.ndarray","The","output","to","be","evaluated","on","an","instance-basis",".","a",":","np.ndarray","The","explanation","to","be","evaluated","on","an","instance-basis",".","Returns","--","--","--","-","list",":","The","evaluation","results","."]
code: def evaluate_instance(
      self,
      model: ModelInterface,
      x: np.ndarray,
      y: np.ndarray,
      a: np.ndarray,
  ) -> List[float]:
      """
      Evaluate instance gets model and data for a single instance as input and returns the evaluation result.
  
      Parameters
      ----------
      model: ModelInterface
          A ModelInteface that is subject to explanation.
      x: np.ndarray
          The input to be evaluated on an instance-basis.
      y: np.ndarray
          The output to be evaluated on an instance-basis.
      a: np.ndarray
          The explanation to be evaluated on an instance-basis.
  
      Returns
      -------
      list:
          The evaluation results.
      """
      # Order indices.
      ordered_indices = np.argsort(a, axis=None)[::-1]
  
      results_instance = np.array([None for _ in self.percentages])
  
      for p_ix, p in enumerate(self.percentages):
          top_k_indices = ordered_indices[: int(self.a_size * p / 100)]
  
          x_perturbed = self.perturb_func(  # type: ignore
              arr=x,
              indices=top_k_indices,
          )
  
          warn.warn_perturbation_caused_no_change(
              x=x, x_perturbed=x_perturbed
          )
  
          # Predict on perturbed input x and store the difference from predicting on unperturbed input.
          x_input = model.shape_input(
              x_perturbed, x.shape, channel_first=True
          )
          class_pred_perturb = np.argmax(model.predict(x_input))
  
          # Write a boolean into the percentage results.
          results_instance[p_ix] = int(y == class_pred_perturb)
  
      # Return list of booleans for each percentage.
      return results_instance
  
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 3 for calling the ROAD obj's underlying member method code with example usage: obj.evaluate_instance(model, x, y, a) and returns: results_instance