KBinsDiscretizer calling get_feature_names_out only works for encode = "onehot"

### Describe the bug

When using `KBinsDiscretizer` with encode set to anything but "onehot", calling `get_feature_names_out` on a fitted instance raises an AttributeError as shown below. It looks like as if the `self._encode` attribute is only available when `encode="onehot"`. The example below might look a bit useless, but when integrating  `KBinsDiscretizer` on a `ColumnTransformer`, I usually call `get_feature_names_out` on that instance to see what type of features it produces. This of course does break if any of the transformers used doesn't properly implement the `get_feature_names_out` API.

### Steps/Code to Reproduce

```python
import pandas as pd
from sklearn.preprocessing import KBinsDiscretizer

data = pd.DataFrame({"a":list(range(100))})
kbd = KBinsDiscretizer(n_bins=10, encode='ordinal', strategy='quantile').fit(data)
names = kbd.get_feature_names_out()
```

### Expected Results

The names of the output feature, which is probably the same as the input feature.

### Actual Results

```pytb
Traceback (most recent call last):
  File
line 3251, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-19-fbbefdd5a8b5>", line 1, in <module>
    kbd.get_feature_names_out()
  File "/.venv/lib/python3.9/site-packages/sklearn/preprocessing/_discretization.py", line 396, in get_feature_names_out
    return self._encoder.get_feature_names_out(input_features)
AttributeError: 'KBinsDiscretizer' object has no attribute '_encoder'
```

### Versions

```shell
System:
    python: 3.9.7 (default, Nov 10 2021, 10:51:48)  [Clang 11.1.0 ]
   machine: macOS-10.16-x86_64-i386-64bit
Python dependencies:
          pip: 22.0.3
   setuptools: 58.3.0
      sklearn: 1.0.2
        numpy: 1.22.2
        scipy: 1.8.0
       Cython: None
       pandas: 1.4.1
   matplotlib: 3.5.1
       joblib: 1.1.0
threadpoolctl: 3.1.0
Built with OpenMP: True
```

COMMENT:
```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[31], line 1
----> 1 step_preprocessor.get_feature_names_out()

File /databricks/python3/lib/python3.8/site-packages/sklearn/compose/_column_transformer.py:510, in ColumnTransformer.get_feature_names_out(self, input_features)
    508 transformer_with_feature_names_out = []
    509 for name, trans, column, _ in self._iter(fitted=True):
--> 510     feature_names_out = self._get_feature_name_out_for_transformer(
    511         name, trans, column, input_features
    512     )
    513     if feature_names_out is None:
    514         continue

File /databricks/python3/lib/python3.8/site-packages/sklearn/compose/_column_transformer.py:482, in ColumnTransformer._get_feature_name_out_for_transformer(self, name, trans, column, feature_names_in)
    477 if not hasattr(trans, "get_feature_names_out"):
    478     raise AttributeError(
    479         f"Transformer {name} (type {type(trans).__name__}) does "
    480         "not provide get_feature_names_out."
    481     )
--> 482 return trans.get_feature_names_out(names)

TypeError: get_feature_names_out() takes 1 positional argument but 2 were given
```

@glemaitre , I also have the same problem where the `get_feature_names_out` throws `TypeError` exception.

Could you please advise how do I troubleshoot this without revealing too much confidential info?

Labels: Bug