Skip to content

metric

Metrics to use for training or explanations.

Classes:

Name Description
Metric

Represents a metric for the explainable model.

TorchGlobalMetric

Represent a metric to be used in the training or evaluation process for the whole model (global metric).

TorchLeafMetric

Represent a metric to be used during the training or the evaluation process, per leaf.

DictMetrics

Dictionary of metrics (torch eval etc...) used in training or explain stage.

Metric #

Represents a metric for the explainable model.

TorchGlobalMetric #

Represent a metric to be used in the training or evaluation process for the whole model (global metric).

Parameters:

Name Type Description Default

metric #

partial[Metric]

The torchmetrics metric to use, as partial.

required

on_raw_data #

bool

If set, value are compute from raw data and not preprocessed data (inputs or targets).

False

reduced_dimensions #

tuple[int, ...]

The dimensions to reduce in the statistics. For instance, given a batch with dimensions (batch size x num_timestamps x num_channels), and a reduced_dimensions=(0,2), it returns a per timestamp statistic, averaged over the batch and channels. Default (0,), meaning the statistic is reduced over the batch only.

(0, )

Attributes:

Name Type Description
metric partial[Metric]
on_raw_data bool
reduced_dimensions tuple[int, ...]

metric: partial[torchmetrics.metric.Metric] #

on_raw_data: bool = False #

reduced_dimensions: tuple[int, ...] = (0) #

TorchLeafMetric #

Represent a metric to be used during the training or the evaluation process, per leaf.

Parameters:

Name Type Description Default

metric #

partial[Metric]

The torchmetrics metric to use, as partial.

required

on_raw_data #

If set, value are compute from raw data and not preprocessed data (inputs or targets).

required

reduced_dimensions #

The dimensions to reduce in the statistics. For instance, given a batch with dimensions (batch size x num_timestamps x num_channels), and a reduced_dimensions=(0,2), it returns a per timestamp statistic, averaged over the batch and channels. Default (0,), meaning the statistic is reduced over the batch only.

required

Attributes:

Name Type Description
metric partial[Metric]
on_raw_data bool
reduced_dimensions tuple[int, ...]

metric: partial[torchmetrics.metric.Metric] #

on_raw_data: bool = False #

reduced_dimensions: tuple[int, ...] = (0) #

DictMetrics #

Dictionary of metrics (torch eval etc...) used in training or explain stage.

If a metric is: - from torchmetrics, it will be computed globally (for the whole model) and per leaf. - a TorchGlobalMetric, it will be computed globally only. - a TorchLeafMetric, it will be computed per leaf only.

In the training stage, metrics help to monitor the training. In the explain stage, metrics are displayed in XpViz along with explanations. Dictionary keys are will be used as metric names in XpViz.