Repository navigation
Conversation
Explicit knot_locations take priority over target-aware placement, so no selector reads y. With target_aware=True the B/M/I splines still emitted a LeakageWarning and reported uses_target_ / spec.uses_target as True, because target use was derived from target_aware alone. BaseSplineTransformer.is_supervised now returns True only for target-aware placement without knot_locations; the leakage warning, uses_target_ and the representation spec follow it. Fixes #185
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 #185.
With explicit
knot_locationsandtarget_aware=True,BSplineTransformer,MSplineTransformerandISplineTransformeremitted aLeakageWarningand reporteduses_target_ == True, andget_representation_spec().uses_targetwasTrueas well, although no selector readsyon that path.Root cause
RepresentationSpecMixin.is_supervised(pretab/core/representation.py) returnsrequires_y or target_aware.uses_target_, the spec flag andwarn_target_leakageall read it.BaseSplineTransformer.fitskips the target-aware selector whenknot_locationsis set, but nothing told the mixin.Fix
BaseSplineTransformeroverridesis_supervised(pretab/expansion/spline/base.py):bool(self.target_aware) and self.knot_locations is None. The leakage warning,uses_target_andRepresentationSpec.uses_targetfollow it. The knot placement itself is unchanged.Behaviour changes
knot_locationsemit noLeakageWarningand reportuses_target_ == Falseandspec.uses_target == False, whatevertarget_awareis.knot_locationsare unchanged: they still warn and reportTrue.knot_locationsis a standalone-transformer option thatPreprocessordoes not accept, so preprocessor lineage is unaffected.Not included
A fitted transformer whose
target_awareis changed withset_paramsbut not refit still derives the flag from the current parameter. Recording target use at fit time would add fitted state, change fingerprints and touch every family, so it is left for a separate issue.Documentation
BaseSplineTransformerdocstring (knot_locations) and the newis_superviseddocstring.docs/core_concepts/target_awareness.md("The fitted-usage flag"): a B/M/I spline with explicitknot_locationsreportsFalseand emits noLeakageWarning, even withtarget_aware=True.Tests
In
tests/core/test_supervised_contract.py:test_explicit_knot_locations_are_not_target_aware(B, M and I splines): noLeakageWarning(escalated to an error),uses_target_andspec.uses_targetareFalse, and the output is independent ofy. Fails onmain, passes here.test_target_aware_spline_without_knots_stays_supervised: guard that passes on both.Reproduction
The script from #185 on this branch:
Checks
just test: 4680 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.expansion.spline.base; no import direction changes.Merge notes
main.pretab/expansion/spline/base.py(thefitdocstring and a target-length check) in a different part of the class, and extends the paragraph on ignored targets intarget_awareness.md. The second commit here moves this PR's sentence into the fitted-usage section, so Git merges the two branches cleanly, and this branch merges cleanly with every open per-issue branch (fix(binning): reject edges the soft encoding cannot use #150 to fix(preprocessor): name constant columns by label in the policy check #184).