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.ResultCompareMixinContains the results of the univariate statistical drift calculation and provides plotting functionality.
Creates a new
AbstractCalculatorResultinstance.- Parameters
results_data (pd.DataFrame) – The data returned by the Calculator.
- 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
kindparameter:driftplots drift per
Chunkfor a single feature of a chunked data set.
distributionplots feature distribution per
Chunk. Joyplot for continuous features, stacked bar charts for categorical features.
- Parameters
kind (str, default=`drift`) – The kind of plot you want to have. Allowed values are drift` and
distribution.- Returns
fig – A
Figureobject containing the requested drift plot.Can be saved to disk using the
write_image()method or shown rendered on screen using theshow()method.- Return type
plotly.graph_objs._figure.Figure
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 ['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()