secmlt.metrics package#

Submodules#

secmlt.metrics.classification module#

Classification metrics for machine-learning models and for attack performance.

class secmlt.metrics.classification.Accuracy[source]#

Bases: object

Class for computing accuracy of a model on a dataset.

class secmlt.metrics.classification.AccuracyEnsemble[source]#

Bases: Accuracy

Robust accuracy of a model on multiple attack runs.

class secmlt.metrics.classification.AttackSuccessRate(y_target: float | Tensor | None = None)[source]#

Bases: Accuracy

Single attack success rate from attack results.

class secmlt.metrics.classification.EnsembleSuccessRate(y_target: float | Tensor | None = None)[source]#

Bases: AccuracyEnsemble

Worst-case success rate of multiple attack runs.

secmlt.metrics.classification.accuracy(y_pred: Tensor, y_true: Tensor) Tensor[source]#

Compute the accuracy on a batch of predictions and targets.

Parameters:
  • y_pred (torch.Tensor) – Predictions from the model.

  • y_true (torch.Tensor) – Target labels.

Returns:

The percentage of predictions that match the targets.

Return type:

torch.Tensor

Module contents#

Metrics to evaluate machine learning models and attacks.