Skip to content

Conversation

Irdasset
Copy link

Reference Issues/PRs

Fixes #26530

What does this implement/fix? Explain your changes.

This implement allow the user to preserve the output dim by adding a parameter preserve_y_dim

Copy link

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 569b3a2. Link to the linter CI: here

@Irdasset Irdasset changed the title add_parameter to keep dim ENH : add_parameter to keep dim in TransformedTargetRegressor Nov 28, 2024
@OmarManzoor
Copy link
Contributor

@glemaitre What do you think about this?

@betatim
Copy link
Member

betatim commented Jan 29, 2025

From one of the comments #26530 (comment) it sounds like we change the number of dimensions. That feels like a bug to me -> can't we fix this without having to introduce a new parameter?

I'm not sure about the answer to that question, just started looking into this. But maybe someone already knows?

Copy link
Contributor

@OmarManzoor OmarManzoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @Irdasset
Instead of adding a new parameter could you handle this by checking the original dimension of y as discussed in the comments on the issue?

@nithish-74
Copy link
Contributor

Hi
Thanks for your work on this!

I had a question regarding the current behavior of TransformedTargetRegressor. From what I understand, even when a 2D target y (e.g., shape (n_samples, 1)) is passed, the inverse transform ends up returning a squeezed 1D array. This breaks compatibility with estimators that strictly expect 2D output (e.g., skorch, custom wrappers, etc.).

I saw in #26530 and #30363 that you're discussing ways to preserve the shape or add a parameter like preserve_y_shape.

👉 Is this still open for contributions or test case additions? I’d like to help or maybe try adding a patch if needed.

Thanks again!

@jeremiedbb
Copy link
Member

The solution that was adopted was to not introduce a parameter and directly fix the behavior because it was a bug. It has been fixed by #31563, so we can close this PR. Thanks for the contributions.

@jeremiedbb jeremiedbb closed this Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TransformedTargetRegressor forces 1d y shape to regressor
5 participants