dataeval.utils.thresholds.ConstantThreshold

class dataeval.utils.thresholds.ConstantThreshold(lower=None, upper=None)

A Threshold implementation that returns a constant lower and or upper threshold value.

lower

The constant lower threshold value. Defaults to None, meaning there is no lower threshold.

Type:

Optional[float]

upper

The constant upper threshold value. Defaults to None, meaning there is no upper threshold.

Type:

Optional[float]

Raises:
  • ValueError – raised when an argument was given using an incorrect type or name:

  • ValueError – raised when the ConstantThreshold could not be created using the given argument values:

Examples

>>> data = np.array(range(10))
>>> t = ConstantThreshold(lower=None, upper=0.1)
>>> t(data)
(None, 0.1)
classmethod parse_object(obj)

Instantiate a Threshold subclass from a dictionary.

The dictionary must contain a "type" key whose value matches a registered threshold_type string (e.g. "constant", "standard_deviation", "zscore"). The remaining key/value pairs are forwarded as keyword arguments to the matching subclass constructor.

Parameters:
obj : dict[str, Any]

Dictionary representation of a threshold. The "type" key is popped from the dict during parsing.

Returns:

An instance of the matching Threshold subclass.

Return type:

Threshold

Raises:

ValueError – If "type" is missing or does not match any registered threshold subclass.