nannyml.drift.multivariate.domain_classifier.result module

Contains the results of the data reconstruction drift calculation and provides plotting functionality.

class nannyml.drift.multivariate.domain_classifier.result.Metric(display_name, column_name)

Bases: tuple

Create new instance of Metric(display_name, column_name)


Alias for field number 1


Alias for field number 0

class nannyml.drift.multivariate.domain_classifier.result.Result(results_data: DataFrame, column_names: List[str], categorical_column_names: List[str], continuous_column_names: List[str], timestamp_column_name: Optional[str] = None)[source]

Bases: PerMetricResult[Metric], ResultCompareMixin

Class wrapping the results of the classifier for drift detection and providing plotting functionality.

Initialize a DomainClassifierCalculator results object.

  • results_data (pd.DataFrame) – Results data returned by a DomainClassifierCalculator.

  • column_names (List[str]) – A list of column names indicating which columns contain feature values.

  • categorical_column_names (List[str]) – Subset of categorical features to be included in calculation.

  • continuous_column_names (List[str]) – Subset of continuous features to be included in calculation.

  • timestamp_column_name (Optional[str], default=None) – The name of the column containing the timestamp of the model prediction. If not given, plots will not use a time-based x-axis but will use the index of the chunks instead.

keys() List[Key][source]

Create a list of keys where each Key is a namedtuple(‘Key’, ‘properties display_names’).

plot(kind: str = 'drift', *args, **kwargs) Figure[source]

Render plots for metrics returned by the multivariate classifier for drift detection.


kind (str, default='drift') – The kind of plot you want to have. Value can currently only be ‘drift’.


InvalidArgumentsException – when an unknown plot kind is provided.:


fig – A Figure object containing the requested drift plot.

Can be saved to disk using the write_image() method or shown rendered on screen using the show() method.

Return type:



>>> import nannyml as nml
>>> # Load synthetic data
>>> reference_df, analysis_df, _ = nml.load_synthetic_car_loan_dataset()
>>> # Define feature columns
>>> feature_column_names = [
...     col for col in reference_df.columns
...     if col not in non_feature_columns
>>> ]
>>> calc = nml.DomainClassifierCalculator(
...     feature_column_names=feature_column_names,
...     timestamp_column_name='timestamp',
...     chunk_size=5000
>>> )
>>> results = calc.calculate(analysis_df)
>>> figure = results.plot()