Processor#

class sdm.processing.base.Processor#

Bases: Module, ABC

Base processor for tensor-aware table transformations.

A Processor defines a reusable transformation on TableTensor for feature, target and output preprocessing. A Processor learns any required state via fit(), and applies the transformation via transform(). Implementations preserve batch dimensions, and preserve rows unless documented otherwise. Batch dimensions are processed independently.

fit(), transform(), and fit_transform() are no-ops for stypes outside of handles_stypes.

handles_stypes: frozenset[Stype]#

Semantic types this processor operates on.

requires_fit: bool#

Whether this processor requires fitting.

property is_fitted: bool#

Whether the processor has all state required for transformation.

static as_processor(processor: object) → Processor#

Normalize a processor-like object to a Processor.

Parameters:

processor (object) – A processor-like object. A Processor is returned as-is, a callable is wrapped as a stateless processor, and a sequence of processor-like objects is normalized to Sequential.

Return type:

Processor

fit(table: TableTensor, *, generator: Generator | None = None) → Self#

Fit the processor.

Parameters:
  • table (TableTensor) – The table used to compute the processor state.

  • generator (Generator | None) – Pseudorandom number generator used for sampling.

Return type:

Self

transform(table: TableTensor) → TableTensor#

Transform table.

Parameters:

table (TableTensor) – The table to transform.

Returns:

The transformed table.

Return type:

TableTensor

forward(table: TableTensor) → TableTensor#

Alias of transform().

Parameters:

table (TableTensor)

Return type:

TableTensor

fit_transform(table: TableTensor, *, generator: Generator | None = None) → TableTensor#

Fit the processor and transform table.

Parameters:
  • table (TableTensor) – The table to fit on and transform.

  • generator (Generator | None) – Pseudorandom number generator used for sampling.

Returns:

The transformed table.

Return type:

TableTensor