Entropy
- class xaitk_saliency.impls.saliency_metric.entropy.Entropy(clip_range: tuple[float, float] | None = None)
Implementation of the SaliencyMetric interface to calculate entropy.
Entropy is a statistical measure of randomness that quantifies the amount of information in a saliency map. High entropy indicates complex, detailed information, while low entropy suggests uniform or less informative regions.
- Attributes:
- clip_range (tuple[float, float] | None): Optional (min, max) range to clip
saliency values before computing entropy.
Methods
Compute the entropy of a saliency map.
from_configInstantiate a new instance of this class given the configuration JSON-compliant dictionary encapsulating initialization arguments.
Generates a configuration dictionary for the Entropy metric instance.
get_default_configGenerate and return a default configuration dictionary for this class.
get_implsDiscover and return a set of classes that implement the calling class.
is_usableCheck whether this class is available for use.
- __init__(clip_range: tuple[float, float] | None = None) None
Initialize the Entropy metric.
- Args:
- clip_range (tuple[float, float] | None): Optional (min, max) value range to
clip the saliency map before computing entropy. The metric computation does a min-max normalization if clip_range is not provided. If input already contains a [-1,1] normalized saliency map, the following clip ranges can be used: - Full Saliency: clip_range = (-1, 1) - Positive Saliency: clip_range = (0, 1) - Negative Saliency: clip_range = (-1, 0)
- compute(sal_map: ndarray) float
Compute the entropy of a saliency map.
Entropy is computed using scipy.stats.entropy on the clipped/normalized saliency map. If clip_range is provided, the metric computation only performs range clipping and does not perform normalization. However, if clip_range is not provided, the metric computation performs only a min-max normalization.
- Args:
sal_map (np.ndarray): The input saliency map.
- Returns:
float: The entropy value of the saliency map.
- Warnings:
UserWarning: If ref_sal_map is provided, it is ignored for entropy computation.
- get_config() dict[str, Any]
Generates a configuration dictionary for the Entropy metric instance.
- Returns:
dict[str, Any]: Configuration data representing the sensor and scenario.