Skip to content

component

component

Classes:

Name Description
Component

Abstract base for all evaluation components.

Component pydantic-model

Bases: ABC, BaseModel

Abstract base for all evaluation components.

Each component computes one quality or privacy metric from an EvaluationDataset and exposes a jinja_context property for HTML report rendering.

Subclasses should override from_evaluation_dataset to perform their metric-specific computation.

Fields:

name pydantic-field

Display name used in JSON summaries and the HTML report.

score = EvaluationScore() pydantic-field

The computed EvaluationScore for this component.

jinja_context cached property

Template context dict for Jinja2 rendering, keyed by name, score, and figure HTML.

from_evaluation_dataset(evaluation_dataset, config=None) staticmethod

Create a component from an EvaluationDataset.

Subclasses override this to compute their specific metric.

Parameters:

Name Type Description Default
evaluation_dataset EvaluationDataset

Paired reference/output data.

required
config SafeSynthesizerParameters | None

Optional pipeline configuration parameters.

None

Returns:

Type Description
Component

A new component instance with computed scores.

Source code in src/nemo_safe_synthesizer/evaluation/components/component.py
@staticmethod
def from_evaluation_dataset(
    evaluation_dataset: EvaluationDataset, config: SafeSynthesizerParameters | None = None
) -> Component:
    """Create a component from an ``EvaluationDataset``.

    Subclasses override this to compute their specific metric.

    Args:
        evaluation_dataset: Paired reference/output data.
        config: Optional pipeline configuration parameters.

    Returns:
        A new component instance with computed scores.
    """
    return Component()  # ty: ignore[missing-argument]

get_json()

Serialize the component score to a JSON string.

Source code in src/nemo_safe_synthesizer/evaluation/components/component.py
def get_json(self) -> str:
    """Serialize the component score to a JSON string."""
    return self.score.model_dump_json()

is_nonempty(dfs) staticmethod

Return True if all provided DataFrames are non-None and non-empty.

Source code in src/nemo_safe_synthesizer/evaluation/components/component.py
@staticmethod
def is_nonempty(dfs: None | pd.DataFrame | list[pd.DataFrame | None]) -> bool:
    """Return ``True`` if all provided DataFrames are non-``None`` and non-empty."""
    if dfs is None:
        return False
    if isinstance(dfs, pd.DataFrame):
        dfs = [dfs]
    return all([df is not None and not df.empty for df in dfs])