nannyml.base module
Module containing base classes for drift calculation.
- class nannyml.base.AbstractCalculator(chunk_size: Optional[int] = None, chunk_number: Optional[int] = None, chunk_period: Optional[str] = None, chunker: Optional[Chunker] = None, timestamp_column_name: Optional[str] = None)[source]
Bases:
ABC
Base 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:
ABC
Contains 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
AbstractCalculator
class there will be a correspondingAbstractCalculatorResult
implementation.Creates a new
AbstractCalculatorResult
instance.- 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: Optional[Union[str, List[str]]] = None, *args, **kwargs) AbstractCalculatorResult [source]
Returns filtered result metric data.
- class nannyml.base.AbstractEstimator(chunk_size: Optional[int] = None, chunk_number: Optional[int] = None, chunk_period: Optional[str] = None, chunker: Optional[Chunker] = None, timestamp_column_name: Optional[str] = None)[source]
Bases:
ABC
Base 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:
ABC
Contains 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
DriftCalculator
class there will be an associatedDriftResult
implementation.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: Optional[Union[str, List[str]]] = None, *args, **kwargs) AbstractEstimatorResult [source]
Returns result metric data.