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, y_pred_column_name: ~typing.Optional[str] = None, y_true_column_name: ~typing.Optional[str] = None, 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: 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.

Parameters:
  • 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.

Examples

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