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: Injector

Hides 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.DataFrame with column names or numpy.ndarray with 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: Injector

Shifts 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.

class menelaus.injection.feature_manipulation.FeatureSwapInjector[source]

Bases: Injector

Swaps two features/columns of a given dataset with each other. Accepts pandas.DataFrame with column names or numpy.ndarray with column indices.

Ref. Souza et al. [2020]

menelaus.injection.injector

class menelaus.injection.injector.Injector[source]

Bases: ABC

Abstract base class for drift injection callables. Classes using this pattern should implement a __call__ function, and also make use of the _preprocess() and _postprocess type handling capabilities of this class.

When called, an Injector typically accepts either pandas.DataFrame or numpy.ndarray data, 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: Injector

Resamples the data over a specified window, per a generated Dirichlet distribution (with specified alpha) over all labels. Accepts pandas.DataFrame with column names or numpy.ndarray with 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: Injector

Joins two [TODO or more?] classes in a unique class. Accepts pandas.DataFrame with column names or numpy.ndarray with column indices.

Ref. Souza et al. [2020]

class menelaus.injection.label_manipulation.LabelProbabilityInjector[source]

Bases: Injector

Resamples the data over a specified window, with altered probability for specified classes (and uniform probability for remaining classes). Accepts pandas.DataFrame with column names or numpy.ndarray with 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]

class menelaus.injection.label_manipulation.LabelSwapInjector[source]

Bases: Injector

Swaps two classes in a target column of a given dataset with each other. Accepts pandas.DataFrame with column names or numpy.ndarray with column indices.

Ref. Souza et al. [2020]

menelaus.injection.noise

class menelaus.injection.noise.BrownianNoiseInjector[source]

Bases: Injector

Adds Brownian noise to a column of a given dataset. Accepts pandas.DataFrame with column names or numpy.ndarray with column indices. Calls random_walk for full computation.

Ref. Fields et al. [2019]