quantus.metrics.base_batched module
- class quantus.metrics.base_batched.BatchedMetric(*args, **kwargs)
Bases:
Metric
,ABC
Alias to quantus.Metric, will be removed in next major release.
- Attributes:
disable_warnings
A helper to avoid polluting test outputs with warnings.
display_progressbar
A helper to avoid polluting test outputs with tqdm progress bars.
get_params
List parameters of metric.
Methods
__call__
(model, x_batch, y_batch, a_batch, ...)This implementation represents the main logic of the metric and makes the class object callable.
batch_preprocess
(data_batch)If data_batch has no a_batch, will compute explanations.
custom_batch_preprocess
(*, model, x_batch, ...)Implement this method if you need custom preprocessing of data or simply for creating/initialising additional attributes or assertions before a data_batch can be evaluated.
custom_postprocess
(*, model, x_batch, ...)Implement this method if you need custom postprocessing of results or additional attributes.
custom_preprocess
(*, model, x_batch, ...)Implement this method if you need custom preprocessing of data, model alteration or simply for creating/initialising additional attributes or assertions.
evaluate_batch
(model, x_batch, y_batch, ...)Evaluates model and attributes on a single data batch and returns the batched evaluation result.
explain_batch
(model, x_batch, y_batch)Compute explanations, normalise and take absolute (if was configured so during metric initialization.) This method should primarily be used if you need to generate additional explanation in metrics body. It encapsulates typical for Quantus pre- and postprocessing approach. It will do few things: - call model.shape_input (if ModelInterface instance was provided) - unwrap model (if ModelInterface instance was provided) - call explain_func - expand attribution channel - (optionally) normalise a_batch - (optionally) take np.abs of a_batch.
general_preprocess
(model, x_batch, y_batch, ...)Prepares all necessary variables for evaluation.
generate_batches
(data, batch_size)Creates iterator to iterate over all batched instances in data dictionary.
interpret_scores
()Get an interpretation of the scores.
plot
([plot_func, show, path_to_save])Basic plotting functionality for Metric class.