class_docstr: Implementation of the Attribution Localization by Kohlbrenner et al., 2020.
  
  Attribution Localization implements the ratio of positive attributions within the target to the overall
  attribution. High scores are desired, as it means, that the positively attributed pixels belong to the
  targeted object class.
  
  References:
      1) Max Kohlbrenner et al., "Towards Best Practice in Explaining Neural Network Decisions with LRP."
         IJCNN (2020): 1-7.
  
  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","Attribution","Localization","by","Kohlbrenner","et","al.",",","2020",".","Attribution","Localization","implements","the","ratio","of","positive","attributions","within","the","target","to","the","overall","attribution",".","High","scores","are","desired",",","as","it","means",",","that","the","positively","attributed","pixels","belong","to","the","targeted","object","class",".","References",":","1",")","Max","Kohlbrenner","et","al.",",","``","Towards","Best","Practice","in","Explaining","Neural","Network","Decisions","with","LRP",".","''","IJCNN","(","2020",")",":","1-7",".","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
  ----------
  x: np.ndarray
      The input to be evaluated on an instance-basis.
  a: np.ndarray
      The explanation to be evaluated on an instance-basis.
  s: np.ndarray
      The segmentation to be evaluated on an instance-basis.
  
  Returns
  -------
  float
      The evaluation results.
docstr_tok: ["Evaluate","instance","gets","model","and","data","for","a","single","instance","as","input","and","returns","the","evaluation","result",".","Parameters","--","--","--","--","--","x",":","np.ndarray","The","input","to","be","evaluated","on","an","instance-basis",".","a",":","np.ndarray","The","explanation","to","be","evaluated","on","an","instance-basis",".","s",":","np.ndarray","The","segmentation","to","be","evaluated","on","an","instance-basis",".","Returns","--","--","--","-","float","The","evaluation","results","."]
code: def evaluate_instance(
      self,
      x: np.ndarray,
      a: np.ndarray,
      s: np.ndarray,
  ) -> float:
      """
      Evaluate instance gets model and data for a single instance as input and returns the evaluation result.
  
      Parameters
      ----------
      x: np.ndarray
          The input to be evaluated on an instance-basis.
      a: np.ndarray
          The explanation to be evaluated on an instance-basis.
      s: np.ndarray
          The segmentation to be evaluated on an instance-basis.
  
      Returns
      -------
      float
          The evaluation results.
      """
  
      if np.sum(s) == 0:
          warn.warn_empty_segmentation()
          return np.nan
  
      # Prepare shapes.
      a = a.flatten()
      s = s.flatten().astype(bool)
  
      # Compute ratio.
      size_bbox = float(np.sum(s))
      size_data = np.prod(x.shape[1:])
      ratio = size_bbox / size_data
  
      # Compute inside/outside ratio.
      inside_attribution = np.sum(a[s])
      total_attribution = np.sum(a)
      inside_attribution_ratio = float(
          inside_attribution / total_attribution
      )
  
      if not ratio <= self.max_size:
          warn.warn_max_size()
      if inside_attribution_ratio > 1.0:
          warn.warn_segmentation(inside_attribution, total_attribution)
          return np.nan
      if not self.weighted:
          return inside_attribution_ratio
      else:
          return float(inside_attribution_ratio * ratio)
  
file_path: Quantus/quantus/metrics/localisation/attribution_localisation.py
imports: import sys
  from typing import Callable, Dict, List, Optional
  import numpy
  from quantus.helpers import asserts, warn
  from quantus.helpers.enums import DataType, EvaluationCategory, ModelType, ScoreDirection
  from quantus.metrics.base import Metric
label_desc: Use image node_id 3 for calling the AttributionLocalisation obj's underlying member method code with example usage: obj.evaluate_instance(x, a, s) and returns: np, np, inside_attribution_ratio, float