Repository navigation
Conversation
Fitting a Dirichlet LSS model with the default preprocessing failed with "X and y must have same length. Got 160 and 480". PreTab flattens the target it receives, so a target matrix of shape (n_samples, n_targets) reached the target-aware numerical encoders as n_samples * n_targets scalar targets. This affected PLE, the default numerical method, and spline placement with target_aware=True; only target-free methods such as standardization worked. The data module now reduces a regression target matrix to one column before fitting the preprocessor by projecting it onto its first principal axis. Scalar targets and classification labels are passed through unchanged, and the model still trains on the full target matrix.
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.
Problem
Fitting a Dirichlet LSS model with the default preprocessing fails before training starts:
PreTab flattens the target it receives (
np.asarray(y).ravel()), so the(n_samples, n_components)target matrix reaches the target-aware numerical encoders asn_samples * n_componentsscalar targets. This affects:numerical_method="ple", which is the default, andtarget_aware=True(fails withoperands could not be broadcast together with shapes (64,) (192,)).Only target-free methods such as
"standardization"work. The existing Dirichlet tests all setnumerical_method="standardization"explicitly, which is why this was not caught.Fix
TabularDataModule.preprocess_datanow reduces a regression target matrix to a single column before fitting the preprocessor, by projecting it onto its first principal axis. Target-aware placement only needs a scalar signal that varies with the target, and this is the direction along which the targets vary most. For a two-component target it is equivalent to using either column.Scalar targets (1-D or a single column) and classification labels are passed through unchanged, so existing fits are not affected. The model itself still trains on the full target matrix.
An alternative would be to raise an actionable error that asks for a target-free
numerical_method. I went with the projection so that the documentedfit(X, y, family="dirichlet")call works with default settings, but I am happy to switch if you prefer the stricter behaviour.Tests
tests/integration/test_lss_base.py: Dirichlet fit with PLE and with a target-aware spline, each with an automatic and an explicit validation split. All four cases fail onmainand pass with this change.tests/data/test_datamodule.py: unit tests for the projection (scalar targets unchanged, aligned 1-D output, two-component equivalence, constant targets).ruff check,ruff format --checkandpyrightpass on the changed files. I rantests/data,tests/integration/test_lss_base.py,tests/lifecycle,tests/distributions,tests/contractsandtests/boundarieslocally (macOS, Python 3.13).One note:
TestSaveLoad::test_load_predictions_matchfails for me whentests/dataruns beforetests/integration/test_lss_base.py, on unchangedmainas well. It compares predictions withrtol=1e-4and noatol, so a value close to zero trips it on float32 rounding (2.2e-08absolute difference). I left it out of this PR.