ballet.eng.misc module

class ballet.eng.misc.BoxCoxTransformer(threshold, lmbda=0.0)[source]

Bases: ballet.eng.base.ConditionalTransformer

Conditionally apply the Box-Cox transformation

In the fit stage, determines which variables (columns) have absolute skew above threshold. In the transform stage, applies the Box-Cox transformation of 1+x to each variable selected previously.

Parameters
  • threshold (float) – skew threshold.

  • lmbda (float) – power parameter of the Box-Cox transform. Defaults to 0.0

class ballet.eng.misc.ColumnSelector(cols)[source]

Bases: ballet.eng.base.BaseTransformer

Select one or more columns from a DataFrame

Parameters

cols (Union[str, List[str]]) – column or columns to select

transform(X, **transform_kwargs)[source]
class ballet.eng.misc.ComputedValueTransformer(func, pass_y=False)[source]

Bases: ballet.eng.base.BaseTransformer

Compute a value on the training data and transform to a constant

For example, compute the mean of a column of the training data, then transform any input array by producing an output of the same shape but filled with the computed mean.

Parameters
  • func (Callable) – function to apply during fit

  • pass_y (bool) – whether to pass y to the function during fit

fit(X, y=None, **fit_kwargs)[source]
transform(X, **transform_kwargs)[source]
class ballet.eng.misc.IdentityTransformer[source]

Bases: sklearn.preprocessing._function_transformer.FunctionTransformer

Simple transformer that passes through its input

class ballet.eng.misc.NamedFramer(name)[source]

Bases: ballet.eng.base.BaseTransformer

Convert object to named 1d DataFrame

If transformation is successful, the resulting object is a DataFrame with a name attribute as given.

Parameters

name (str) – name for resulting DataFrame

transform(X, **transform_kwargs)[source]
class ballet.eng.misc.ValueReplacer(value, replacement)[source]

Bases: ballet.eng.base.BaseTransformer

Replace instances of some value with some replacement

Parameters
  • value – value to replace (checked by equality testing)

  • replacement – replacement

transform(X, **transform_kwargs)[source]