menelaus.injection
This module contains classes with which to artificially inject drift into a dataset.
menelaus.injection.feature_manipulation
- class menelaus.injection.feature_manipulation.FeatureCoverInjector[source]
Bases:
InjectorHides a feature, then treats it as a shared concept by which to group the data. Afterwards samples are uniformly drawn from each group. Accepts
pandas.DataFramewith column names ornumpy.ndarraywith column indices.Note: * This function cannot hide a feature over a window, as the appearance of the
column outside the window may raise errors.
Ref. Souza et al. [2020]
- class menelaus.injection.feature_manipulation.FeatureShiftInjector[source]
Bases:
InjectorShifts a column in a dataset by a fixed value relative to the current mean. Formula: *
column = column + (shift_factor * (alpha + mean_column))The alpha is a small value used to inject drift even if the mean is 0.
menelaus.injection.injector
- class menelaus.injection.injector.Injector[source]
Bases:
ABCAbstract base class for drift injection callables. Classes using this pattern should implement a
__call__function, and also make use of the_preprocess()and_postprocesstype handling capabilities of this class.When called, an
Injectortypically accepts eitherpandas.DataFrameornumpy.ndarraydata, along with other parameters for the injection technique it is modeling, and returns the data with drift injected over a specified window.
menelaus.injection.label_manipulation
- class menelaus.injection.label_manipulation.LabelDirichletInjector[source]
Bases:
InjectorResamples the data over a specified window, per a generated Dirichlet distribution (with specified alpha) over all labels. Accepts
pandas.DataFramewith column names ornumpy.ndarraywith column indices.Notes: * If all labels are not given weights, unexpected behavior may cause all un-specified classes to be given uniform resampling chance.
Ref. Guo et al. [2020]
- class menelaus.injection.label_manipulation.LabelJoinInjector[source]
Bases:
InjectorJoins two [TODO or more?] classes in a unique class. Accepts
pandas.DataFramewith column names ornumpy.ndarraywith column indices.Ref. Souza et al. [2020]
- class menelaus.injection.label_manipulation.LabelProbabilityInjector[source]
Bases:
InjectorResamples the data over a specified window, with altered probability for specified classes (and uniform probability for remaining classes). Accepts
pandas.DataFramewith column names ornumpy.ndarraywith column indices.Note: * this function can perform tweak-one and minority shift * When a class is not present in the window specified, but specified in
class_probabilities, the probability value is uniformly divided into the remaining classes in the window.Ref. Guo et al. [2020]