`set_output` API no longer changing the name of the output columns

### Describe the bug

In scikit-learn versions prior to 1.3.0 I was able to change the name of the output data using the set_output API, in version 1.3.0 the output data names are no longer changed. Is this a bug? Or was I using this functionality incorrectly?

### Steps/Code to Reproduce

``` python
from sklearn.base import OneToOneFeatureMixin, TransformerMixin, BaseEstimator
import pandas as pd

df = pd.DataFrame({"a": [-1, -100, 10, 0, 4]})

class PlusN(OneToOneFeatureMixin, TransformerMixin, BaseEstimator):
    def __init__(self, n: int=1) -> None:
        super().__init__()
        self.n = 10
    def transform(self, X):
        return X + self.n
    def fit(self, X):
        self.feature_names_in_ = X.columns
        return self
    def get_feature_names_out(self, input_features = None):
        feat = super().get_feature_names_out(input_features)
        return [f + "_NEW_NAME" for f in feat]
    
PlusN().set_output(transform="pandas").fit_transform(df)
```

### Expected Results

In scikit-learn versions less than 1.3.0 I see this on the output. With the output data renamed, as I would expect.
![image](https://github.com/scikit-learn/scikit-learn/assets/38221700/6d1065f9-5719-480a-8992-5d49b694e398)



### Actual Results

Now in scikit-learn 1.3.0 the column is not renamed.
![image](https://github.com/scikit-learn/scikit-learn/assets/38221700/53ce02c3-3213-4274-ac35-0c4d54c5ffeb)


### Versions

```shell
System:
    python: 3.10.4 | packaged by conda-forge | (main, Mar 30 2022, 08:38:02) [MSC v.1916 64 bit (AMD64)]
executable: c:\<some path>\python.exe
   machine: Windows-10-10.0.22621-SP0

Python dependencies:
      sklearn: 1.3.0
          pip: 23.1.2
   setuptools: 58.1.0
        numpy: 1.23.4
        scipy: 1.9.2
       Cython: None
       pandas: 1.5.3
   matplotlib: 3.6.0
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: vcomp
       filepath: C:\<>\.env\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: C:\<>\.env\Lib\site-packages\numpy\.libs\libopenblas.FB5AE2TYXYH2IJRDKGDGQ3XBKLKTF43H.gfortran-win_amd64.dll
        version: 0.3.20
threading_layer: pthreads
   architecture: SkylakeX
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: C:\<>\.env\Lib\site-packages\scipy.libs\libopenblas-57db09cfe174768fb409a6bb5a530d4c.dll
        version: 0.3.18
threading_layer: pthreads
   architecture: SkylakeX
    num_threads: 8
```

COMMENT:
Surely we are missing some documentation there.

From your code, you can get that something goes wrong when calling:

```python
PlusN().set_output(transform="pandas").fit(df).get_feature_names_out()
```

It will raise a `NotFittedError` because the `OneToOneFeatureMixin` will check for the fitted attribute `n_features_in_`.

The mechanism of `set_output` will set `columns=None` if an exception is raised and thus you don't see any changes.

To have the correct behaviour, you need to define:

```python
    def fit(self, X):
        self.n_features_in_ = len(X.columns)
        self.feature_names_in_ = X.columns
        return self
]
```

and you will get the expected behaviour.

We should improve our documentation to state which fitted attribute we expect to be defined for the `set_output` to work.

Labels: Documentation