tlc.client.torch.metrics.metrics_aggregators.aggregator#

Base class for all Aggregators.

Module Contents#

Classes#

Class

Description

Aggregator

Base class for aggregating metrics across multiple batches of data.

API#

class tlc.client.torch.metrics.metrics_aggregators.aggregator.Aggregator#

Base class for aggregating metrics across multiple batches of data.

This class is designed to be extended by specific types of aggregators that implement their own logic for computing aggregate metrics from a batch of data and across multiple batches.

A single input metric can result in 0 or more output metrics, depending on the data type and schema of the input metric.

reset() None#

Resets the internal state of the aggregator.

column_schemas_finalized() bool#

Checks if column schemas have been finalized.

Returns:

True if the column schemas are set, otherwise False.

set_column_schemas(column_schemas: dict[str, tlc.core.schema.Schema]) None#

Sets the column schemas used for aggregation.

The column schemas are used to determine which columns are computable and how to compute aggregate values from them. If columns are missing a schema, a inferred schema will be used.

Parameters:

column_schemas – A dictionary mapping column names to their respective schemas.

aggregate_batch(computed_metrics: dict[str, list[Any]]) None#

Aggregate metrics for a single batch.

This method computes the aggregate metrics for a single batch and updates the internal state accordingly.

Parameters:

computed_metrics – A dictionary containing the computed metrics for each column in the batch.

finalize_aggregates() dict[str, Any]#

Finalizes the aggregation process and returns the aggregate metrics.

Returns:

A dictionary containing the final aggregate metrics across all batches.

abstract compute_batch_aggregate(computed_metrics: dict[str, list[Any]]) dict[str, Any]#

Computes the aggregate metrics for a single batch.

This is an abstract method that must be implemented in subclasses.

Parameters:

computed_metrics – A dictionary containing the computed metrics for each column in the batch.

Returns:

A dictionary containing the aggregate metrics for this batch.

abstract aggregate_across_batches() dict[str, Any]#

Computes the final aggregate metrics across all batches.

This is an abstract method that must be implemented in subclasses.

Returns:

A dictionary containing the final aggregate metrics.