pyrit.score.ScorerMetrics#

class ScorerMetrics[source]#

Bases: object

Base dataclass for storing scorer evaluation metrics.

This class provides methods for serializing metrics to JSON and loading them from JSON files.

__init__() None#

Methods

__init__()

from_json(file_path)

Load the metrics from a JSON file.

to_json()

Convert the metrics to a JSON string.

classmethod from_json(file_path: str | Path) T[source]#

Load the metrics from a JSON file.

Parameters:

file_path (Union[str, Path]) – The path to the JSON file.

Returns:

An instance of ScorerMetrics with the loaded data.

Return type:

ScorerMetrics

Raises:

FileNotFoundError – If the specified file does not exist.

to_json() str[source]#

Convert the metrics to a JSON string.

Returns:

The JSON string representation of the metrics.

Return type:

str