Skip to content

Add KNearestNeighborsImputer #743

@lars-reimann

Description

@lars-reimann

Is your feature request related to a problem?

We currently only have a basic imputer, but there are more sophisticated imputation strategies.

Desired solution

Add a KNearestNeighborsImputer that uses the KNNImputer of scikit-learn internally.

  • Superclass: TableTransformer
  • Constructor parameters:
    • neighbor_count: int,
    • column_names: str | list[str] | None = None (keyword-only). List of columns to transform, if None all columns passed in fit.
    • value_to_replace: float | str | None = None (keyword-only)
  • Attributes:
    • self._wrapped_transformer: sk_KNNImputer | None = None
  • fit:
    • Call _check_columns_exist to ensure columns to transform exist
    • Raise value error if row_count is 0
    • Create a new instance of the KNearestNeighborsImputer, don't mutate it in place
    • Create and fit an sk_KNNImputer and store it in _wrapped_transformer of the copied transformer
  • transform:
    • TransformerNotFittedError if transformer is not fitted

    • Call _check_columns_exist to ensure columns to transform exist

    • Transform with the _wrapped_transformer

Possible alternatives (optional)

No response

Screenshots (optional)

No response

Additional Context (optional)

No response

Metadata

Metadata

Labels

releasedIncluded in a release

Type

No type

Projects

Status

✔️ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions