nannyml.drift.univariate.result module

Contains the results of the univariate statistical drift calculation and provides plotting functionality.

class nannyml.drift.univariate.result.Result(results_data: pandas.core.frame.DataFrame, column_names: List[str], categorical_column_names: List[str], continuous_column_names: List[str], categorical_method_names: List[str], continuous_method_names: List[str], timestamp_column_name: Optional[str], chunker: nannyml.chunk.Chunker, analysis_data: Optional[pandas.core.frame.DataFrame] = None, reference_data: Optional[pandas.core.frame.DataFrame] = None)[source]

Bases: nannyml.base.Abstract2DResult, nannyml.plots.blueprints.comparisons.ResultCompareMixin

Contains the results of the univariate statistical drift calculation and provides plotting functionality.

Creates a new AbstractCalculatorResult instance.


results_data (pd.DataFrame) – The data returned by the Calculator.

keys() List[nannyml._typing.Key][source]
plot(kind: str = 'drift', *args, **kwargs) Optional[plotly.graph_objs._figure.Figure][source]

Renders plots for metrics returned by the univariate distance drift calculator.

For any feature you can render the statistic value or p-values as a step plot, or create a distribution plot. Select a plot using the kind parameter:

  • drift

    plots drift per Chunk for a single feature of a chunked data set.

  • distribution

    plots feature distribution per Chunk. Joyplot for continuous features, stacked bar charts for categorical features.


kind (str, default=`drift`) – The kind of plot you want to have. Allowed values are drift` and distribution.


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
>>> 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.UnivariateDriftCalculator(
...   column_names=column_names,
...   timestamp_column_name='timestamp',
...   continuous_methods=['kolmogorov_smirnov', 'jensen_shannon', 'wasserstein'],
...   categorical_methods=['chi2', 'jensen_shannon', 'l_infinity'],
... ).fit(reference)
>>> res = calc.calculate(analysis)
>>> res = res.filter(period='analysis')
>>> for column_name in res.continuous_column_names:
...  for method in res.continuous_method_names:
...    res.plot(kind='drift', column_name=column_name, method=method).show()