nannyml.data_quality.missing.calculator module

Drift calculator using Reconstruction Error as a measure of drift.

class nannyml.data_quality.missing.calculator.MissingValuesCalculator(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 = StandardDeviationThreshold{'std_lower_multiplier': 3, 'std_upper_multiplier': 3, 'offset_from': <function nanmean>})[source]

Bases: AbstractCalculator

MissingValuesCalculator implementation using missing value rate as a measure of data quality.

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. Missing Values will be calculated for each entry in this list.

  • normalize (bool, default=True) – Whether to provide the missing value ratio (True) or the absolute number of missing 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.

  • threshold (Threshold, default=StandardDeviationThreshold) – The threshold you wish to evaluate values on. Defaults to a StandardDeviationThreshold with default options. The other available value is ConstantThreshold.


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