used in
    :meth:`fit_transform`. For classification targets, `StratifiedKFold` is used
    and for continuous targets, `KFold` is used.

shuffle : bool, default=True
    Whether to shuffle the data in :meth:`fit_transform` before splitting into
    folds. Note that the samples within each split will not be shuffled.

random_state : int, RandomState instance or None, default=None
    When `shuffle` is True, `random_state` affects the ordering of the
    indices, which controls the randomness of each fold. Otherwise, this
    parameter has no effect.
    Pass an int for reproducible output across multiple function calls.
    See :term:`Glossary <random_state>`.

Attributes
----------
encodings_ : list of shape (n_features,) or (n_features * n_classes) of                     ndarray
    Encodings learnt on all of `X`.
    For feature `i`, `encodings_[i]` are the encodings matching the
    categories listed in `categories_[i]`. When `target_type_` is
    "multiclass", the encoding for feature `i` and class `j` is stored in
    `encodings_[j + (i * len(classes_))]`. E.g., for 2 features (f) and
    3 classes (c), encodings are ordered:
    f0_c0, f0_c1, f0_c2, f1_c0, f1_c1, f1_c2,

categories_ : list of shape (n_features,) of ndarray
    The categories of each input feature determined during fitting or
    specified in `categories`
    (in order of the features in `X` and corresponding with the output
    of :meth:`transform`).

target_type_ : str
    Type of target.

target_mean_ : float
    The overall mean of the target. This value is only used in :meth:`transform`
    to encode categories.

n_features_in_ : int
    Number of features seen during :term:`fit`.

feature_names_in_ : ndarray of shape (`n_features_in_`,)
    Names of features seen during :term:`fit`. Defined only when `X`
    has feature names that are all strings.

classes_ : ndarray or None
    If `target_type_` is 'binary' or 'multiclass', holds the label for each class,
    otherwise `None`.

See Also
--------
OrdinalEncoder : Performs an ordinal (integer) encoding of the categorical features.
    Contrary to TargetEncoder, this encoding is not supervised. Treating the
    resulting encoding as a numerical features therefore lead arbitrarily
    ordered values and therefore typically lead to lower predictive performance
    when used as preprocessing for a classifier or regressor.
OneHotEncoder : Performs a one-hot encoding of categorical features. This
    unsupervised encoding is better suited for low cardinality categorical
    variables as it generate one new feature per unique category.

References
----------
.. [MIC] :doi:`Micci-Barreca, Daniele. "A preprocessing scheme for high-cardinality
   categorical attributes in classification and prediction problems"
   SIGKDD Explor. Newsl. 3, 1 (July 2001), 27–32. <10.1145/507533.507538>`

Examples
--------
With `smooth="auto"`, the smoothing parameter is set to an empirical Bayes estimate:

>>> import numpy as np
>>> from sklearn.preprocessing import TargetEncoder
>>> X = np.array([["dog"] * 20 + ["cat"] * 30 + ["snake"] * 38], dtype=object).T
>>> y = [90.3] * 5 + [80.1] * 15 + [20.4] * 5 + [20.1] * 25 + [21.2] * 8 + [49] * 30
>>> enc_auto = TargetEncoder(smooth="auto")
>>> X_trans = enc_auto.fit_transform(X, y)

>>> # A high `smooth` parameter puts more weight on global mean on the categorical
>>> # encodings:
>>> enc_high_smooth = TargetEncoder(smooth=5000.0).fit(X, y)
>>> enc_high_smooth.target_mean_
np.float64(44...)
>>> enc_high_smooth.encodings_
[array([44..., 44..., 44...])]

>>> # On the other hand, a low `smooth` parameter puts more weight on target
>>> # conditioned on the value of the categorical:
>>> enc_low_smooth = TargetEncoder(smooth=1.0).fit(X, y)
>>> enc_low_smooth.encodings_
[array([20..., 80..., 43...])]
