Skip to content

feat: FittedImputer string_sentinels field, transform wiring, and serialization round-trip #182

Description

@DEVunderdog

Parent

#176

What to build

Add string_sentinels: dict[str, list[str]] as a dataclass field on FittedImputer (default empty dict) and wire it through transform and serialization:

  • transform(): pass string_sentinels=self.string_sentinels to the existing _resolve_effective_nulls call, so replace-semantics string sentinel normalization happens at transform time on new data — including test-split data in production.
  • to_dict(): serialize string_sentinels as a plain JSON-compatible dict.
  • from_dict(): restore string_sentinels; a payload without the key defaults to {} for backwards compatibility with imputers serialized before this feature.

Acceptance criteria

  • FittedImputer.string_sentinels field exists, defaults to {}
  • transform() calls _resolve_effective_nulls(df, string_sentinels=self.string_sentinels)
  • to_dict() output includes the "string_sentinels" key
  • from_dict() restores the field; a dict without the key deserializes to {}
  • A FittedImputer constructed with string_sentinels={"status": ["N/A", "missing"]} and serialized via to_dict() / from_dict() produces the same transform() output as the original object when the test DataFrame contains "N/A" in status
  • A FittedImputer deserialized from an old-format dict (no string_sentinels key) transforms data identically to one constructed with string_sentinels={}
  • No change in behaviour for FittedImputer instances where string_sentinels is empty
  • Unit tests in tests/unit/imputation/test_fitted_imputer.py covering all criteria above
  • Docstrings updated per ADR-0034

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions