Repository navigation
Conversation
Preprocessor passed only its numerical columns, as an unlabelled array,
to apply_constant_policy, which reported positions in that array. With a
categorical column before them, policy={"constant": "error"} (or "warn")
pointed at a different, non-constant column of X.
apply_constant_policy takes optional labels for the checked columns and
lists the constant ones by label; the Preprocessor passes its numerical
feature labels. Standalone transformers check their whole input and
keep the positional message.
Fixes #183
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #183.
Preprocessor(policy={"constant": "error"}), or"warn", reported a constant numerical column by its position among the numerical columns only. With a categorical column before it, the message pointed at a different, non-constant column ofX.Root cause
Preprocessor.fitpassedX[numerical_features].to_numpy()toapply_constant_policy(pretab/core/policy.py). That function reported positions in the array it received, and the array had lost the column labels.Fix
apply_constant_policytakes an optionallabelsargument naming the columns of the checked array. With labels, the message lists the constant columns by label, for examplePreprocessor received constant (zero-variance) column(s) ['flag'].Preprocessor.fitpasseslabels=numerical_features, the original column labels, so integer labels are reported as given.BasePreTabTransformer) check their whole input, where a position is correct, and keep the positional message.Behaviour changes
Preprocessor's constant-column error and warning name the columns by label instead of a misleading position. The exception and warning types are unchanged.Documentation
apply_constant_policydocstring: the newlabelsargument.docs/representations/choosing_a_method.md(edge cases): the policy's error or warning names the constant columns by label.Tests
In
tests/core/test_policy.py:test_preprocessor_constant_policy_names_the_constant_column(string and integer labels,"error"and"warn"): fails onmain, passes here.test_standalone_constant_policy_still_reports_positions: guard that passes on both.Reproduction
The script from #183 on this branch:
Checks
just test: 4679 passed, 59 skipped, 7 xfailed; coverage 95.71% (gate 90%).scripts/quickstart.pypasses.just docs: strict build succeeds.just check: all pre-commit and pre-push hooks pass (file hygiene, ruff format, ruff lint, prettier, pyright with 0 errors).pretab.core.policygains a keyword argument only; no import direction changes.Merge notes
main.tests/core/test_policy.py, at a different place. Git merges this branch cleanly with every open per-issue branch (fix(binning): reject edges the soft encoding cannot use #150 to fix(validation): check task consistency for a polars Series target #182).