Repository navigation
Conversation
On the uniform / quantile path the ReLU expansion reused the feature maps' endpoint-inclusive centers, so its last ramp max(0, x - c) started at the training maximum and was identically zero on every training row: output_dim=k gave only k - 1 informative columns. The ReLU now places output_dim + 1 range-spanning locations and drops the right endpoint, so the first center stays at the minimum and no ramp starts at the training maximum. A zero-range feature keeps output_dim equal centers. RBF / sigmoid / tanh and the target-aware path are unchanged. The ReLU docstring and the functional-expansions page describe the placement. Fixes #83
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 #83.
With unsupervised placement (
target_aware=False,"uniform"or"quantile"),ReLUExpansionTransformerput its last center exactly at the training maximum. The rampmax(0, x - c)of that center was zero on every training row, sooutput_dim=kgave onlyk - 1informative columns per feature. This happened on every fit of the standalone transformer, whose default placement is unsupervised"quantile", and ofPreprocessor(numerical_method="relu", target_aware=False, ...).Root cause
BaseCenterExpansion.fitplaced the centers of every feature map throughRBFPlacementAdapter.get_centers, which uses endpoint-inclusive locations (include_endpoints=True). That convention suits kernels that respond on both sides of a center (RBF, sigmoid, tanh). For the one-sided ReLU ramp, a center at the maximum is degenerate.Fix
BaseCenterExpansion.fittakes the unsupervised centers from a new hook,_unsupervised_centers(adapter, x, n_centers). The default implementation makes the sameadapter.get_centers(x, None, n_centers, n_centers)call as before. The target-aware path still callsadapter.get_centerswith the adaptive bounds.ReLUExpansionTransformer._unsupervised_centersplacesn_centers + 1range-spanning locations and drops the right endpoint. The first center stays at the training minimum, which gives the linear term, and no ramp starts at the maximum.Behaviour changes
linspace(min, max, output_dim + 1)[:-1], and quantile centers are the matching quantiles without the 100th percentile. Every column is now non-zero on the training data.output_dimequal centers.Documentation
ReLUExpansionTransformerdocstring: on the unsupervised path, the centers are the firstoutput_dimofoutput_dim + 1range-spanning locations, and why the right endpoint is dropped.docs/representations/functional_expansions.md, ReLU entry: the same in prose.BaseCenterExpansion._unsupervised_centersand of the ReLU override.Tests
All tests are in
tests/expansion/functional/test_reluexpansion_transformer.py.test_unsupervised_relu_has_no_dead_column[uniform, quantile]: all 6 columns are non-zero on the training data and have rank 6, the first center is at the minimum and the last is below the maximum. A zero-range feature keepsoutput_dimequal centers. Fails onmain, passes here.test_unsupervised_relu_uniform_centers_drop_the_right_endpoint: the centers equallinspace(min, max, 7)[:-1]. Fails onmain, passes here.test_preprocessor_relu_has_no_constant_column[uniform, quantile]: the issue'sPreprocessorcase withoutput_dim=7gives no constant column and rank 7. Fails onmain, passes here.Reproduction
Output of the script from #83 on this branch:
Checks
just test: 1443 passed, 59 skipped, 7 xfailed; coverage 93.66% (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
main.pretab/expansion/functional/relu.py, in theplacement_strategydocstring. It merges cleanly with this branch. ReLU with"quantile"centers on tied data needs both fixes. On zero-inflated, discrete and top-coded features atoutput_dim=8:pretab/expansion/functional/base.pyand this test file, in other places, and merges cleanly.This change was previously part of #86, which is closed in favour of one pull request per issue.