nannyml.base module¶
Module containing base classes for drift calculation.
- class nannyml.base.AbstractCalculator(chunk_size: int | None = None, chunk_number: int | None = None, chunk_period: str | None = None, chunker: Chunker | None = None, timestamp_column_name: str | None = None)[source]¶
Bases:
ABCBase class for drift calculation.
Creates a new instance of an abstract DriftCalculator.
- Parameters:
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.
timestamp_column_name (str) – The column name of the column containing timestamp information.
- calculate(data: DataFrame, *args, **kwargs) Any[source]¶
Performs a calculation on the provided data.
- fit(reference_data: DataFrame, *args, **kwargs) AbstractCalculator[source]¶
Trains the calculator using reference data.
- class nannyml.base.AbstractCalculatorResult(results_data: DataFrame, *args, **kwargs)[source]¶
Bases:
ABCContains the results of a calculation and provides plotting functionality.
The result of the
calculate()method of aAbstractCalculator.It is an abstract class containing shared properties and methods across implementations. For each
AbstractCalculatorclass there will be a correspondingAbstractCalculatorResultimplementation.Creates a new
AbstractCalculatorResultinstance.- Parameters:
results_data (pd.DataFrame) – The data returned by the Calculator.
- DEFAULT_COLUMNS = ('key', 'chunk_index', 'start_index', 'end_index', 'start_date', 'end_date', 'period')¶
- filter(period: str = 'analysis', metrics: str | List[str] | None = None, *args, **kwargs) AbstractCalculatorResult[source]¶
Returns filtered result metric data.
- class nannyml.base.AbstractEstimator(chunk_size: int | None = None, chunk_number: int | None = None, chunk_period: str | None = None, chunker: Chunker | None = None, timestamp_column_name: str | None = None)[source]¶
Bases:
ABCBase class for drift calculation.
Creates a new instance of an abstract DriftCalculator.
- Parameters:
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.
timestamp_column_name (str) – The column name of the column containing timestamp information.
- estimate(data: DataFrame, *args, **kwargs) Any[source]¶
Performs a calculation on the provided data.
- fit(reference_data: DataFrame, *args, **kwargs) AbstractEstimator[source]¶
Trains the calculator using reference data.
- class nannyml.base.AbstractEstimatorResult(results_data: DataFrame)[source]¶
Bases:
ABCContains the results of a drift calculation and provides additional functionality such as plotting.
The result of the
calculate()method of aDriftCalculator.It is an abstract class containing shared properties and methods across implementations. For each
DriftCalculatorclass there will be an associatedDriftResultimplementation.Creates a new DriftResult instance.
- Parameters:
results_data (pd.DataFrame) – The result data of the performed calculation.
- DEFAULT_COLUMNS = ['key', 'chunk_index', 'start_index', 'end_index', 'start_date', 'end_date', 'period']¶
- filter(period: str = 'analysis', metrics: str | List[str] | None = None, *args, **kwargs) AbstractEstimatorResult[source]¶
Returns result metric data.