Aggregator#

class tpcp.validate.Aggregator(*, return_raw_scores: bool = True)[source]#

Base class for aggregators.

You can subclass this class to create your own aggregators. The only thing you should change, is to overwrite the aggregate method. Everything else should not be modified.

Custom aggregators can then be used to wrap return values of score functions or they can be passed as default_aggregator to the Scorer class.

Methods

__call__(value)

Set the value of the aggregator.

aggregate(values, datapoints)

Aggregate the values.

clone()

Create a new instance of the class with all parameters copied over.

get_params([deep])

Get parameters for this algorithm.

get_value()

Return the value wrapped by aggregator.

set_params(**params)

Set the parameters of this Algorithm.

__init__(*, return_raw_scores: bool = True) None[source]#
_assert_is_all_valid(values: Sequence[Any], _key_name: str)[source]#

Check if all scoring values are consistently of the same type.

This methods is called on the first aggregator instance acountered of a scoring value.

It’s role is to check, if all other values are of the same type (aka the same class and same config) as the first one.

_get_emtpy_instance() Self[source]#

Return an empty instance of the aggregator with the same config, but no value.

aggregate(values: Sequence[T], datapoints: Sequence[Dataset]) AggReturnType[source]#

Aggregate the values.

clone() Self[source]#

Create a new instance of the class with all parameters copied over.

This will create a new instance of the class itself and all nested objects

get_params(deep: bool = True) dict[str, Any][source]#

Get parameters for this algorithm.

Parameters:
deep

Only relevant if object contains nested algorithm objects. If this is the case and deep is True, the params of these nested objects are included in the output using a prefix like nested_object_name__ (Note the two “_” at the end)

Returns:
params

Parameter names mapped to their values.

get_value() T[source]#

Return the value wrapped by aggregator.

set_params(**params: Any) Self[source]#

Set the parameters of this Algorithm.

To set parameters of nested objects use nested_object_name__para_name=.

Examples using tpcp.validate.Aggregator#

Custom Scorer

Custom Scorer

Tensorflow/Keras

Tensorflow/Keras