Talip7/scikit-learn-issues-multilabel huggingface dataset:
UserWarning: X has feature names, but PowerTransformer was fitted without feature names

### Describe the bug

When using pandas dataframes and a `TransformedTargetRegressor` with `PowerTransformer` with `set_output(transform="pandas")`, I get this warning:

> UserWarning: X has feature names, but PowerTransformer was fitted without feature names

The warning does not arise when using other estimators (e.g. `StandardScaler`) but only with `PowerTransformer`.

The problem seems to originate from the `inverse_transform` implementation of `PowerTransformer`.

### Steps/Code to Reproduce

```python
from sklearn.datasets import load_iris
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.compose import TransformedTargetRegressor
from sklearn.preprocessing import PowerTransformer, StandardScaler

X, y = load_iris(return_X_y=True, as_frame=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42)

# This works fine:
pipeline = TransformedTargetRegressor(
    regressor=LinearRegression(),
    transformer=StandardScaler().set_output(transform="pandas")
)
pipeline.fit(X_train, y_train)
y_test_pred = pipeline.predict(X_test)

# But this gets a warning:
pipeline = TransformedTargetRegressor(
    regressor=LinearRegression(),
    transformer=PowerTransformer().set_output(transform="pandas")
)
pipeline.fit(X_train, y_train)
y_test_pred = pipeline.predict(X_test)
```

### Expected Results

No warning

### Actual Results

> UserWarning: X has feature names, but PowerTransformer was fitted without feature names

### Versions

```shell
System:
    python: 3.11.9

Python dependencies:
      sklearn: 1.7.1
          pip: 25.2
   setuptools: 65.5.0
        numpy: 2.0.2
        scipy: 1.15.1
       Cython: None
       pandas: 2.2.3
   matplotlib: 3.10.0
       joblib: 1.4.2
threadpoolctl: 3.5.0
```

COMMENT:
Hi @ThibaultDECO and @35250!

I'd love to contribute to this fix! I see you've identified the solution approach and @35250 mentioned adding regression tests and whatsnew documentation.

I cann help with the ::

1. Comprehensive regression tests- testing the fix with different scenarios:
   - Various pandas DataFrame configurations  
   - Different PowerTransformer parameters
   - Edge cases with mixed feature types
   - Ensuring the fix works across different set_output modes

2. Documentation updates - whatsnew entry and any docstring improvements needed

3. Code review and testing - helping validate the _set_output implementation


@ThibaultDECO Thanks for opening this and the initial PR! Let me know how I can best contribute.

Looking forward to working

Labels: Bug
UserWarning: X has feature names, but PowerTransformer was fitted without feature names

### Describe the bug

When using pandas dataframes and a `TransformedTargetRegressor` with `PowerTransformer` with `set_output(transform="pandas")`, I get this warning:

> UserWarning: X has feature names, but PowerTransformer was fitted without feature names

The warning does not arise when using other estimators (e.g. `StandardScaler`) but only with `PowerTransformer`.

The problem seems to originate from the `inverse_transform` implementation of `PowerTransformer`.

### Steps/Code to Reproduce

```python
from sklearn.datasets import load_iris
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.compose import TransformedTargetRegressor
from sklearn.preprocessing import PowerTransformer, StandardScaler

X, y = load_iris(return_X_y=True, as_frame=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42)

# This works fine:
pipeline = TransformedTargetRegressor(
    regressor=LinearRegression(),
    transformer=StandardScaler().set_output(transform="pandas")
)
pipeline.fit(X_train, y_train)
y_test_pred = pipeline.predict(X_test)

# But this gets a warning:
pipeline = TransformedTargetRegressor(
    regressor=LinearRegression(),
    transformer=PowerTransformer().set_output(transform="pandas")
)
pipeline.fit(X_train, y_train)
y_test_pred = pipeline.predict(X_test)
```

### Expected Results

No warning

### Actual Results

> UserWarning: X has feature names, but PowerTransformer was fitted without feature names

### Versions

```shell
System:
    python: 3.11.9

Python dependencies:
      sklearn: 1.7.1
          pip: 25.2
   setuptools: 65.5.0
        numpy: 2.0.2
        scipy: 1.15.1
       Cython: None
       pandas: 2.2.3
   matplotlib: 3.10.0
       joblib: 1.4.2
threadpoolctl: 3.5.0
```

COMMENT:
Thanks @Aishwarya0811 for jumping in! Great to see multiple folks interested in this.

I’ve already started by adding tests around inverse_transform in PowerTransformer (covering edge cases like empty arrays, dtype preservation, set_output("pandas"), etc.). 

Maybe I can continue focusing on test coverage + updating whatsnew, while you explore strengthening the _set_output implementation? This way we don’t overlap and can review each other’s work.

@ThibaultDECO — does this division of work make sense to you?

If it sounds good, I’ll push a draft PR with the initial tests so we have a base to build on.

Labels: Bug
UserWarning: X has feature names, but PowerTransformer was fitted without feature names

### Describe the bug

When using pandas dataframes and a `TransformedTargetRegressor` with `PowerTransformer` with `set_output(transform="pandas")`, I get this warning:

> UserWarning: X has feature names, but PowerTransformer was fitted without feature names

The warning does not arise when using other estimators (e.g. `StandardScaler`) but only with `PowerTransformer`.

The problem seems to originate from the `inverse_transform` implementation of `PowerTransformer`.

### Steps/Code to Reproduce

```python
from sklearn.datasets import load_iris
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.compose import TransformedTargetRegressor
from sklearn.preprocessing import PowerTransformer, StandardScaler

X, y = load_iris(return_X_y=True, as_frame=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42)

# This works fine:
pipeline = TransformedTargetRegressor(
    regressor=LinearRegression(),
    transformer=StandardScaler().set_output(transform="pandas")
)
pipeline.fit(X_train, y_train)
y_test_pred = pipeline.predict(X_test)

# But this gets a warning:
pipeline = TransformedTargetRegressor(
    regressor=LinearRegression(),
    transformer=PowerTransformer().set_output(transform="pandas")
)
pipeline.fit(X_train, y_train)
y_test_pred = pipeline.predict(X_test)
```

### Expected Results

No warning

### Actual Results

> UserWarning: X has feature names, but PowerTransformer was fitted without feature names

### Versions

```shell
System:
    python: 3.11.9

Python dependencies:
      sklearn: 1.7.1
          pip: 25.2
   setuptools: 65.5.0
        numpy: 2.0.2
        scipy: 1.15.1
       Cython: None
       pandas: 2.2.3
   matplotlib: 3.10.0
       joblib: 1.4.2
threadpoolctl: 3.5.0
```

COMMENT:
Looking at this issue, I notice `QuantileTransformer` has the same problem.

`PowerTransformer` and `QuantileTransformer` are both using the same `_check_data` pattern calling `validate_data` in `inverse_transform`, while all the other transformers in the same module directly call `check_array` in `inverse_transform`.

So for the sake of consistency, I don't mind following the same pattern for the two transformers, but looking at the code it does worry me that we're repeating the same code basically twice in each estimator. A bit of refactoring there might be nice, not sure.

Labels: Bug
UserWarning: X has feature names, but PowerTransformer was fitted without feature names

### Describe the bug

When using pandas dataframes and a `TransformedTargetRegressor` with `PowerTransformer` with `set_output(transform="pandas")`, I get this warning:

> UserWarning: X has feature names, but PowerTransformer was fitted without feature names

The warning does not arise when using other estimators (e.g. `StandardScaler`) but only with `PowerTransformer`.

The problem seems to originate from the `inverse_transform` implementation of `PowerTransformer`.

### Steps/Code to Reproduce

```python
from sklearn.datasets import load_iris
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.compose import TransformedTargetRegressor
from sklearn.preprocessing import PowerTransformer, StandardScaler

X, y = load_iris(return_X_y=True, as_frame=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42)

# This works fine:
pipeline = TransformedTargetRegressor(
    regressor=LinearRegression(),
    transformer=StandardScaler().set_output(transform="pandas")
)
pipeline.fit(X_train, y_train)
y_test_pred = pipeline.predict(X_test)

# But this gets a warning:
pipeline = TransformedTargetRegressor(
    regressor=LinearRegression(),
    transformer=PowerTransformer().set_output(transform="pandas")
)
pipeline.fit(X_train, y_train)
y_test_pred = pipeline.predict(X_test)
```

### Expected Results

No warning

### Actual Results

> UserWarning: X has feature names, but PowerTransformer was fitted without feature names

### Versions

```shell
System:
    python: 3.11.9

Python dependencies:
      sklearn: 1.7.1
          pip: 25.2
   setuptools: 65.5.0
        numpy: 2.0.2
        scipy: 1.15.1
       Cython: None
       pandas: 2.2.3
   matplotlib: 3.10.0
       joblib: 1.4.2
threadpoolctl: 3.5.0
```

COMMENT:
@adrinjalali I fixed the issue for `QuantileTransformer` too in the PR

Labels: Bug
Allow common estimator checks to use `xfail_strict=True`

### Describe the workflow you want to enable

I'd like to be able to use [`parametrize_with_checks`](https://scikit-learn.org/stable/modules/generated/sklearn.utils.estimator_checks.parametrize_with_checks.html) and use "strict mode" to notice when checks that are marked as xfail start passing. But I don't want to turn on strict mode for my whole test suite (`xfail_strict = true` in `pytest.ini`)

### Describe your proposed solution

We use `pytest.mark.xfail` internally when generating all the estimator + check combinations. I think we could pass `strict=True` there to make it a failure for a test, that is marked as xfail, to pass.

https://github.com/scikit-learn/scikit-learn/blob/c5497b7f7eacfaff061cf68e09bcd48aa93d4d6b/sklearn/utils/estimator_checks.py#L456

I think we want to make this behaviour configurable, so we need a new parameter for `parametrize_with_checks`, something like `strict=None` with the option to set it to `True`/`False`.

I'd set the default to `None` so that not setting it does not override the setting in `pytest.ini` (to be checked if this actually works). If you are using `pytest.ini` to control strict mode then not passing `strict` to `parametrize_with_checks` should not change anything.

### Describe alternatives you've considered, if relevant

I tried layering `@pytest.mark.xfail(strict=True)` on top of `@parametrize_with_checks` but that doesn't seem to work.

```python
@pytest.mark.xfail(strict=True)
@parametrize_with_checks(...)
def test_sklearn_compat(estimator, check):
   ...
```

### Additional context

_No response_

COMMENT:
Hi @betatim! 
1. Comprehensive testing** - ensuring the new `strict` parameter works correctly:
    Testing `strict=None` respects pytest.ini settings
    verifying `strict=True/False` overrides work as expected  
    teesting with various estimator check combinations
    edge case validation

2. Documentation - updating docstrings and examples for the new parameter

3. Code review - helping validate the implementation works across different pytest versions

The use case makes perfect sense - being able to catch when xfail tests start passing is crucial for maintaining test quality without forcing strict mode globally.

Would you like me to help with the testing infrastructure or documentation for this feature?

Looking forward to collaborating

Labels: Enhancement
Allow common estimator checks to use `xfail_strict=True`

### Describe the workflow you want to enable

I'd like to be able to use [`parametrize_with_checks`](https://scikit-learn.org/stable/modules/generated/sklearn.utils.estimator_checks.parametrize_with_checks.html) and use "strict mode" to notice when checks that are marked as xfail start passing. But I don't want to turn on strict mode for my whole test suite (`xfail_strict = true` in `pytest.ini`)

### Describe your proposed solution

We use `pytest.mark.xfail` internally when generating all the estimator + check combinations. I think we could pass `strict=True` there to make it a failure for a test, that is marked as xfail, to pass.

https://github.com/scikit-learn/scikit-learn/blob/c5497b7f7eacfaff061cf68e09bcd48aa93d4d6b/sklearn/utils/estimator_checks.py#L456

I think we want to make this behaviour configurable, so we need a new parameter for `parametrize_with_checks`, something like `strict=None` with the option to set it to `True`/`False`.

I'd set the default to `None` so that not setting it does not override the setting in `pytest.ini` (to be checked if this actually works). If you are using `pytest.ini` to control strict mode then not passing `strict` to `parametrize_with_checks` should not change anything.

### Describe alternatives you've considered, if relevant

I tried layering `@pytest.mark.xfail(strict=True)` on top of `@parametrize_with_checks` but that doesn't seem to work.

```python
@pytest.mark.xfail(strict=True)
@parametrize_with_checks(...)
def test_sklearn_compat(estimator, check):
   ...
```

### Additional context

_No response_

COMMENT:
Hello @Aishwarya0811 - thanks for taking the time to think about this issue. There is already a Pull Request that implements the changes. If you have time to review that PR yourself that would be a helpful contribution.

Labels: Enhancement
Docs instructions for installing  LLVM OpenMP with Homebrew may need updating

### Describe the issue linked to the documentation

Environment variables CFLAGS, CXXFLAGS, CXXFLAGS mentioned here:
https://scikit-learn.org/dev/developers/advanced_installation.html#compiler-macos:~:text=Set%20the%20following%20environment%20variables%3A
may be for Intel-based Macs only.

So when trying to do this:
```
make clean
pip install --editable . \
    --verbose --no-build-isolation \
    --config-settings editable-verbose=true
```
I got  `../../meson.build:1:0: ERROR: Compiler /usr/bin/clang cannot compile programs.`

The reason being that `Homebrew` installed `libomp` here: `/opt/homebrew/opt/libomp` and not here`/usr/local/opt/libomp/`.


### Suggest a potential alternative/fix

Modify the env variables that I mentioned above to the right path to `libomp` for M2 macs.

Please note:

- I'm not sure if the variables should be updated or have the two mac versions (Intel vs M1/M2).
- I didn't test that all works for an Intel mac. 
- Modifying the variables to the correct path, I was able to make the new environment.

COMMENT:
My guess is that if you install libomp with brew, you don't need to set any environment variable since we switched to meson (so a while ago) see https://github.com/scikit-learn/scikit-learn/issues/29603. meson will automatically find the compiler with the right OpenMP flags.

It would be super useful that someone with a macOS can double-check this and clean-up this section 🙏.

There was also https://github.com/scikit-learn/scikit-learn/issues/31359 and an PR attempt https://github.com/scikit-learn/scikit-learn/pull/31361, in particular see https://github.com/scikit-learn/scikit-learn/pull/31361#issuecomment-2876202394.

Labels: Documentation
Docs instructions for installing  LLVM OpenMP with Homebrew may need updating

### Describe the issue linked to the documentation

Environment variables CFLAGS, CXXFLAGS, CXXFLAGS mentioned here:
https://scikit-learn.org/dev/developers/advanced_installation.html#compiler-macos:~:text=Set%20the%20following%20environment%20variables%3A
may be for Intel-based Macs only.

So when trying to do this:
```
make clean
pip install --editable . \
    --verbose --no-build-isolation \
    --config-settings editable-verbose=true
```
I got  `../../meson.build:1:0: ERROR: Compiler /usr/bin/clang cannot compile programs.`

The reason being that `Homebrew` installed `libomp` here: `/opt/homebrew/opt/libomp` and not here`/usr/local/opt/libomp/`.


### Suggest a potential alternative/fix

Modify the env variables that I mentioned above to the right path to `libomp` for M2 macs.

Please note:

- I'm not sure if the variables should be updated or have the two mac versions (Intel vs M1/M2).
- I didn't test that all works for an Intel mac. 
- Modifying the variables to the correct path, I was able to make the new environment.

COMMENT:
@lesteve I forgot to check if there was already an issue/PR for this. So sorry about that. 

--------

> It would be super useful that someone with a macOS can double-check this and clean-up this section

~~This is what I did and it didn't work. Unless what you mean is: 
If the env variables are set incorrectly, meson will fail to "automatically find the compiler with the right OpenMP flags."  And it would be good to try without setting these variables at all?~~

edit: never mind

Labels: Documentation
Docs instructions for installing  LLVM OpenMP with Homebrew may need updating

### Describe the issue linked to the documentation

Environment variables CFLAGS, CXXFLAGS, CXXFLAGS mentioned here:
https://scikit-learn.org/dev/developers/advanced_installation.html#compiler-macos:~:text=Set%20the%20following%20environment%20variables%3A
may be for Intel-based Macs only.

So when trying to do this:
```
make clean
pip install --editable . \
    --verbose --no-build-isolation \
    --config-settings editable-verbose=true
```
I got  `../../meson.build:1:0: ERROR: Compiler /usr/bin/clang cannot compile programs.`

The reason being that `Homebrew` installed `libomp` here: `/opt/homebrew/opt/libomp` and not here`/usr/local/opt/libomp/`.


### Suggest a potential alternative/fix

Modify the env variables that I mentioned above to the right path to `libomp` for M2 macs.

Please note:

- I'm not sure if the variables should be updated or have the two mac versions (Intel vs M1/M2).
- I didn't test that all works for an Intel mac. 
- Modifying the variables to the correct path, I was able to make the new environment.

COMMENT:
I'll double-check then.

Labels: Documentation
Docs instructions for installing  LLVM OpenMP with Homebrew may need updating

### Describe the issue linked to the documentation

Environment variables CFLAGS, CXXFLAGS, CXXFLAGS mentioned here:
https://scikit-learn.org/dev/developers/advanced_installation.html#compiler-macos:~:text=Set%20the%20following%20environment%20variables%3A
may be for Intel-based Macs only.

So when trying to do this:
```
make clean
pip install --editable . \
    --verbose --no-build-isolation \
    --config-settings editable-verbose=true
```
I got  `../../meson.build:1:0: ERROR: Compiler /usr/bin/clang cannot compile programs.`

The reason being that `Homebrew` installed `libomp` here: `/opt/homebrew/opt/libomp` and not here`/usr/local/opt/libomp/`.


### Suggest a potential alternative/fix

Modify the env variables that I mentioned above to the right path to `libomp` for M2 macs.

Please note:

- I'm not sure if the variables should be updated or have the two mac versions (Intel vs M1/M2).
- I didn't test that all works for an Intel mac. 
- Modifying the variables to the correct path, I was able to make the new environment.

COMMENT:
> @lesteve I forgot to check if there was already an issue/PR for this. So sorry about that.

No worries at all! This looks to me like a good opportunity to clean up this section actually 😉.

Labels: Documentation
Docs instructions for installing  LLVM OpenMP with Homebrew may need updating

### Describe the issue linked to the documentation

Environment variables CFLAGS, CXXFLAGS, CXXFLAGS mentioned here:
https://scikit-learn.org/dev/developers/advanced_installation.html#compiler-macos:~:text=Set%20the%20following%20environment%20variables%3A
may be for Intel-based Macs only.

So when trying to do this:
```
make clean
pip install --editable . \
    --verbose --no-build-isolation \
    --config-settings editable-verbose=true
```
I got  `../../meson.build:1:0: ERROR: Compiler /usr/bin/clang cannot compile programs.`

The reason being that `Homebrew` installed `libomp` here: `/opt/homebrew/opt/libomp` and not here`/usr/local/opt/libomp/`.


### Suggest a potential alternative/fix

Modify the env variables that I mentioned above to the right path to `libomp` for M2 macs.

Please note:

- I'm not sure if the variables should be updated or have the two mac versions (Intel vs M1/M2).
- I didn't test that all works for an Intel mac. 
- Modifying the variables to the correct path, I was able to make the new environment.

COMMENT:
So, I used `venv` and followed the same steps I did earlier without setting those env variables. (Earlier I also used `venv`). 

Up to here it works well: `python -c "import sklearn; sklearn.show_versions()"`.  But when I try to run `pytest` I get:

```
(sklearn-env-test) *[main][~/projects/scikit-learn]$ pytest
ImportError while loading conftest '/Users/dealeon/projects/scikit-learn/sklearn/conftest.py'.
sklearn/__init__.py:69: in <module>
    from sklearn import __check_build, _distributor_init  # noqa: E402 F401
sklearn/__check_build/__init__.py:54: in <module>
    raise_build_error(e)
sklearn/__check_build/__init__.py:35: in raise_build_error
    raise ImportError(
E   ImportError: No module named 'sklearn.__check_build._check_build'
E   ___________________________________________________________________________
E   Contents of /Users/dealeon/projects/scikit-learn/sklearn/__check_build:
E   __init__.py               __pycache__               meson.build
E   _check_build.pyx
E   ___________________________________________________________________________
E   It seems that scikit-learn has not been built correctly.
E
E   If you have installed scikit-learn from source, please do not forget
E   to build the package before using it. For detailed instructions, see:
E   https://scikit-learn.org/dev/developers/advanced_installation.html#building-from-source
E
E   If you have used an installer, please check that it is suited for your
E   Python version, your operating system and your platform.
```

There is no issue when I **do** set the environment variables.

Labels: Documentation
Docs instructions for installing  LLVM OpenMP with Homebrew may need updating

### Describe the issue linked to the documentation

Environment variables CFLAGS, CXXFLAGS, CXXFLAGS mentioned here:
https://scikit-learn.org/dev/developers/advanced_installation.html#compiler-macos:~:text=Set%20the%20following%20environment%20variables%3A
may be for Intel-based Macs only.

So when trying to do this:
```
make clean
pip install --editable . \
    --verbose --no-build-isolation \
    --config-settings editable-verbose=true
```
I got  `../../meson.build:1:0: ERROR: Compiler /usr/bin/clang cannot compile programs.`

The reason being that `Homebrew` installed `libomp` here: `/opt/homebrew/opt/libomp` and not here`/usr/local/opt/libomp/`.


### Suggest a potential alternative/fix

Modify the env variables that I mentioned above to the right path to `libomp` for M2 macs.

Please note:

- I'm not sure if the variables should be updated or have the two mac versions (Intel vs M1/M2).
- I didn't test that all works for an Intel mac. 
- Modifying the variables to the correct path, I was able to make the new environment.

COMMENT:
OK so the good news is that the build worked and `python -c 'import sklearn'` works fine. To make sure that scikit-learn has been built with OpenMP, can you post the output of `python -c 'import sklearn; sklearn.show_versions()'`?

The issue with `pytest` seems unrelated. Maybe try `python -m pytest` and/or make sure that `pytest` is indeed the one you have installed in your venv with `which pytest`?

Labels: Documentation