Repository navigation
Conversation
QuantilePlacement returned the data quantiles verbatim, so on zero-inflated, top-coded or discrete features the RBF / ReLU / sigmoid / tanh feature maps got repeated centers and exactly duplicated output columns (4 of 8 distinct on a zero-inflated feature). The locations are now made distinct with the supplement_interior_knots helper the splines use: the endpoints (when included) are kept once and the rest is topped up with strictly interior quantile / uniform candidates. Untied data is unchanged, and a zero-range feature keeps its repeated location so the width holds. The feature-map docstrings and the placement guide describe the rule. Fixes #82
This was referenced Oct 16, 2026
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 #82.
With unsupervised
"quantile"placement, which is the default for the standalone feature maps, the RBF, ReLU, sigmoid and tanh expansions repeated centers on tied features (zero-inflated, top-coded or discrete) and produced exactly duplicated output columns. On the issue's zero-inflated feature only 4 of 8 columns were distinct. This also applied throughPreprocessor(numerical_method="rbf", target_aware=False, placement_strategy="quantile").Root cause
QuantilePlacement._placereturned the data quantiles verbatim:spanning_knots(x, n, "quantile")with endpoints, orquantile_knots(x, n)without them. On tied data many of these quantiles coincide, and nothing removed the duplicates.Fix
QuantilePlacement._place(pretab/placement/unsupervised.py) now makes the locations distinct withpretab.core.knots.supplement_interior_knots, the helper that the PR for #56 (#101) adds for the spline knots:include_endpoints=True, the feature-map path, the minimum and maximum are kept once. The interior is made unique and strictly inside the range, then topped up ton_units - 2with strictly interior quantile / uniform candidates.include_endpoints=False, the quantiles are made unique and strictly interior and topped up ton_unitsin the same way.include_endpoints=Trueandn_units <= 2, the locations are the same as before.Behaviour changes
"quantile"centers of the RBF, ReLU, sigmoid and tanh expansions move on tied data. They are now distinct, with the range endpoints kept once and the remaining centers strictly interior. On the issue's zero-inflated feature the centers change from[0.0, 0.0, 0.0, 0.0, 0.0, 1.77, 5.33, 35.36]to[0.0, 1.77, 5.05, 5.33, 15.16, 20.21, 30.31, 35.36]. Untied data and zero-range features give the same centers as before, and the golden regression baselines pass unchanged.QuantilePlacement(include_endpoints=False)also returns unique, strictly interior locations on tied data.Documentation
QuantilePlacementclass docstring (public inpretab.placement): the tied-data rule and the zero-range case.placement_strategyofRBFExpansionTransformer,ReLUExpansionTransformer,SigmoidExpansionTransformerandTanhExpansionTransformer:"quantile"centers stay distinct on tied data.docs/core_concepts/resolution_and_placement.md: the tied-data paragraph added by the PR for Spline knots on tied data land on the range boundary or repeat, producing dead columns and all-zero rows #56 (fix(splines): keep knots unique and strictly interior on tied data #101) now also covers the feature maps.Tests
All tests are in
tests/placement/test_placement.py.test_quantile_placement_returns_distinct_locations_on_tied_data[{True,False}-{zero-inflated,discrete,top-coded}]: 8 distinct locations. Withinclude_endpoints=Truethe endpoints are kept; without them the locations are strictly interior. Fails onmainand on Spline knots on tied data land on the range boundary or repeat, producing dead columns and all-zero rows #56's branch, passes here.test_quantile_feature_map_has_no_duplicate_columns_on_tied_data[{RBF,ReLU,Sigmoid,Tanh}-{zero-inflated,discrete,top-coded}]: 8 of 8 distinct output columns atoutput_dim=8. Fails onmainand on Spline knots on tied data land on the range boundary or repeat, producing dead columns and all-zero rows #56's branch, passes here.test_preprocessor_rbf_has_no_duplicate_columns_on_tied_data: the issue'sPreprocessorcase gives no duplicated column. Fails onmainand on Spline knots on tied data land on the range boundary or repeat, producing dead columns and all-zero rows #56's branch, passes here.Reproduction
Output of the script from #82 on this branch. The script is extended with the two further cases from the issue text, 5 equally likely levels and a top capped at about 30 %, for all four feature maps:
On
mainthe same script prints 4 of 8, 4 of 7, 5 of 8 for every map, and 6 of 8 for every map.Checks
just test: 1478 passed, 59 skipped, 7 xfailed; coverage 93.55% (gate 90%).scripts/quickstart.pypasses.just docs: strict build succeeds.just check: all pre-commit and pre-push hooks pass (ruff format, ruff lint, prettier, file hygiene, pyright with 0 errors).Merge notes
fix/56-unique-interior-knots. The fix callssupplement_interior_knots, which the PR for Spline knots on tied data land on the range boundary or repeat, producing dead columns and all-zero rows #56 (fix(splines): keep knots unique and strictly interior on tied data #101) introduces inpretab/core/knots.py. Onmainalone this change fails at import. Adding the helper here as well would duplicate Spline knots on tied data land on the range boundary or repeat, producing dead columns and all-zero rows #56's code and cause an add/add conflict inpretab/core/knots.py. GitHub shows only this issue's commit. The PR must be retargeted tomainafter the PR for Spline knots on tied data land on the range boundary or repeat, producing dead columns and all-zero rows #56 (fix(splines): keep knots unique and strictly interior on tied data #101) merges.relu.pyare separate. ReLU with"quantile"centers on tied data needs both fixes. On the zero-inflated, discrete and top-coded features of the tests here, atoutput_dim=8:pretab/expansion/spline/base.py. Resolve it as described in the PR for Spline knots on tied data land on the range boundary or repeat, producing dead columns and all-zero rows #56 (fix(splines): keep knots unique and strictly interior on tied data #101). This commit's own files conflict with no other per-issue PR.This change was previously part of #86, which is closed in favour of one pull request per issue.