lir.transform.composite module

class lir.transform.composite.CategoricalCompositeTransformer(factory: Callable[[], Transformer], category_field: str)[source]

Bases: Transformer

Composite transformer.

Incoming data is categorized by a category field. For each category, a separate transformer is used.

Parameters:
  • factory (Callable[[], Transformer]) – Value passed via factory.

  • category_field (str) – Value passed via category_field.

apply(instances: InstanceData) InstanceData[source]

Apply the specialized transformers for all instances in instances, based on their categories.

Parameters:

instances (InstanceData) – Input instances to be processed by this method.

Returns:

Instance data object produced by this operation.

Return type:

InstanceData

fit(instances: InstanceData) Self[source]

Fit the transformer for all categories found in instances.

Parameters:

instances (InstanceData) – Input instances to be processed by this method.

Returns:

This composite transformer instance after fitting category models.

Return type:

Self