Add Categorical Feature Support to `IterativeImputer`

### Describe the workflow you want to enable

I want to impute missing values in categorical columns using a similar approach to `IterativeImputer`, which currently works only for continuous data. Specifically, I want to enable the following workflow:

- Identify and handle categorical columns in the dataset
- Use classifier models (e.g., RandomForestClassifier) to impute missing values in categorical columns based on other features
- Integrate with existing pipelines seamlessly, without needing to separate and impute categorical columns manually

### Describe your proposed solution

Extend the current `IterativeImputer` class (or create a new class, such as `IterativeCategoricalImputer`) to handle categorical data:

- Detect categorical columns automatically (e.g., using `dtype='object'` or `category`) or accept them via a `categorical_features` parameter
- Encode the categorical variables using an internal encoder (e.g., `LabelEncoder`)
- Use a classifier model (e.g., `RandomForestClassifier`) instead of a regression model for those columns
- Predict only the missing values, then inverse transform the predictions back to the original categories

This would enable more robust and automatic preprocessing for datasets that have numeric and categorical features.

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

- Manually encoding categorical variables, using a classifier-based imputation strategy outside of `IterativeImputer`
- Using other libraries like `autoimpute` or `fancyimpute`, which support mixed-type imputation but lack full integration with Scikit-learn pipelines
- Creating separate imputation steps for categorical and numeric features and merging them later, which adds complexity and can introduce data leakage risks

None of these are as clean or pipeline-friendly as a built-in solution.


### Additional context

This feature would make `IterativeImputer` more powerful and suitable for real-world datasets that include both numeric and categorical variables with missing values.

I'm currently working with datasets like this in my own data science projects and would be interested in contributing a prototype or proof-of-concept if this idea is accepted by the maintainers.

COMMENT:
I agree that what you propose would be a great usability improvement and make this model much more practical and useful.

> Encode the categorical variables using an internal encoder (e.g., LabelEncoder)
> Use a classifier model (e.g., RandomForestClassifier) instead of a regression model for those columns
> Predict only the missing values, then inverse transform the predictions back to the original categories

I am not sure why you would need `LabelEncoder`-based preprocessing. `RandomForestClassifier` and all scikit-learn classifiers do that automatically internally if you fit with `str` object class labels for instance.

However, I agree that `RandomForestClassifier` and the majority of scikit-learn estimator do not currently accept categorical inputs (yet) so we need to take care of this (see below).

For an implementation point of view, we might want to deprecate the `estimator` hyperparameter and related public fitted attributes in favor of a pair of `regressor` and `classifier` hyperparameter. We could use `RandomForestRegressor` and `RandomForestClassifier` by default for the sake of consistency.

But since they do not accept categorical inputs, a shared `preprocessor` argument.

By default, all of them could be left to `None` in which case, internally, we would have:

```python
classifier = RandomForestClassifier(n_estimators=10, max_depth=5)
regressor = RandomForestRegressor(n_estimators=10, max_depth=5)
preprocessor = ColumnTransformer(
    [
        (
            "categorical",
            OrdinalEncoder(
                handle_unknown="use_encoded_value", unknown_value=-1
            ),
            categorical_features,
         )
    ],
    remainder="passthrough",
)
```

Or alternatively, we could use the `TargetEncoder` instead of `OrdinalEncoder`, or the `FeatureUnion` of both together.

Then the data would be `fit_transformed` by the shared `preprocessor` before being iteratively fed to the instances of `regressor` and `classifier` for each feature to impute.

Maybe the default preprocessor could be in charge of including the `SimpleImputer` with strategy `"most_frequent"` for categorical variable and `"mean"` or `"median"` for continuous variables. We could then drop the `initial_strategy` parameter of the `IterativeImputer` imputer class since the users would have full flexibility to configure there own default imputation via the `preprocessor` argument.


What is problematic:

- the `sample_posterior` is not easy to adapt to `RandomForestRegressor` because this is a point-estimator of the conditional expectation `E[y|X]` rather than a probabilistic regressor. Since it's disabled by default, maybe this is fine: we can leave it to the user to explicitly pass probabilistic regressor if they way to use this option. I think this option is the reason why we use `BayesianRidge` as the default base regressor, though.
- `n_nearest_features` does not support categorical features. Maybe we could raise `NotImplementedError` if enabled in the presence of non-continuous features.

Labels: New Feature