nannyml.data_quality.unseen.calculator module

Drift calculator using Reconstruction Error as a measure of drift.

class nannyml.data_quality.unseen.calculator.UnseenValuesCalculator(column_names: typing.Union[str, typing.List[str]], normalize: bool = True, timestamp_column_name: typing.Optional[str] = None, chunk_size: typing.Optional[int] = None, chunk_number: typing.Optional[int] = None, chunk_period: typing.Optional[str] = None, chunker: typing.Optional[nannyml.chunk.Chunker] = None, threshold: nannyml.thresholds.Threshold = ConstantThreshold{'lower': None, 'upper': 0})[source]

Bases: nannyml.base.AbstractCalculator

UnseenValuesCalculator implementation using unseen value rate as a measure of data quality.

This only works for categorical features. Seen values are the ones encountered on the reference data.

Creates a new MissingValuesCalculator instance.

  • column_names (Union[str, List[str]]) – A string or list containing the names of features in the provided data set. Unseen Values will be calculated for each entry in this list.

  • normalize (bool, default=True) – Whether to provide the unseen value ratio (True) or the absolute number of unseen values (False).

  • timestamp_column_name (str) – The name of the column containing the timestamp of the model prediction.

  • chunk_size (int) – Splits the data into chunks containing chunks_size observations. Only one of chunk_size, chunk_number or chunk_period should be given.

  • chunk_number (int) – Splits the data into chunk_number pieces. Only one of chunk_size, chunk_number or chunk_period should be given.

  • chunk_period (str) – Splits the data according to the given period. Only one of chunk_size, chunk_number or chunk_period should be given.

  • chunker (Chunker) – The Chunker used to split the data sets into a lists of chunks.


>>> import nannyml as nml
>>> reference, analysis, _ = nml.load_synthetic_car_price_dataset()
>>> column_names = [col for col in reference.columns if col not in ['timestamp', 'y_pred', 'y_true']]
>>> calc = nml.UnseenValuesCalculator(
...     column_names=column_names,
...     timestamp_column_name='timestamp',
... ).fit(reference)
>>> res = calc.calculate(analysis)
>>> for column_name in res.column_names:
...     res = res.filter(period='analysis', column_name=column_name).plot().show()