Skip to content

Add add_target_to_X helper and check init parameter types in encoders - #1047

Merged
solegalli merged 2 commits into
narwhals-migrationfrom
narwhals-encoding-init-checks
Sep 15, 2026
Merged

solegalli merged 2 commits into
narwhals-migrationfrom
narwhals-encoding-init-checks

Conversation

@solegalli

Copy link
Copy Markdown
Collaborator

Shared changes for the encoder PRs (#1026, #1028, #1029, #1031, #1032).

  • Add add_target_to_X(nw_X, y) in feature_engine/encoding/_helper_functions.py. It adds y to X as a column, pairing rows by position, so list, array and series targets work. With pandas, the column takes the index of X. It is used by MeanEncoder, OrdinalEncoder, WoEEncoder and DecisionTreeEncoder.
  • MeanEncoder uses the helper.
  • Check that string parameters are strings before comparing them to the allowed values: unseen (check_parameter_unseen), missing_values (CategoricalInitMixinNA and _check_param_missing_values) and CountEncoder's encoding_method.
  • Fix the get_feature_names_out error message, which printed a literal {input_features}.
  • MeanEncoder and CountEncoder tests: init tests at the top, init params assigned correctly, and error messages matched in every pytest.raises.

solegalli and others added 2 commits September 15, 2026 13:30
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant