Repository navigation
Conversation
_validate_task_target inspected only NumPy, pandas, list and tuple targets, so with a polars Series y the task_validation diagnostic was skipped in Preprocessor, CrossFittedTransformer and RepresentationSearchCV: "warn" reported nothing and "raise" let scikit-learn's own error surface instead of InvalidParamError. A polars Series, detected without importing polars, is now inspected through its NumPy values. Fixes #181
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 #181.
With a polars Series
y, thetask_validationdiagnostic was skipped inPreprocessor,CrossFittedTransformerandRepresentationSearchCV."warn"reported nothing, and"raise"let scikit-learn's own error surface instead of the documentedInvalidParamError.Root cause
_validate_task_target(pretab/core/validation.py) returned early unlessywas a NumPy array, pandas object, list or tuple.Fix
_is_polars_series(y): detects a polars Series without importing polars, like the existingis_polars_frame._validate_task_targetinspects a polars Series throughSeries.to_numpy(). The check itself is unchanged.Behaviour changes
task_validation="raise"raisesInvalidParamErrorand"warn"emitsConfigWarningfor the same mismatches as with NumPy or pandas targets.task_validation="off"(the default) is unaffected.Documentation
_validate_task_targetdocstring.docs/core_concepts/resolution_and_placement.md(task_validation): which target containers the check reads, and that it skips targets it cannot classify, such as ones with missing values.Tests
In
tests/core/test_validation.py:test_task_target_inspects_a_polars_series(continuous and text targets,"warn"and"raise"): fails onmain, passes here (skipped without polars).test_task_target_leaves_consistent_or_missing_polars_targets_quiet(binary, bool, null): guard that passes on both.test_preprocessor_task_validation_applies_to_a_polars_target(PreprocessorandCrossFittedTransformer): fails onmain, passes here.Reproduction
The script from #181 on this branch:
Checks
just test: 4684 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.validation, and polars stays an optional import. No import direction changes.Merge notes
main.pretab/core/validation.py, in other parts of the module. Git merges this branch cleanly with every open per-issue branch (fix(binning): reject edges the soft encoding cannot use #150 to fix(registry): honour preprocessor_compatible for categorical methods #180).