Overview

Scikit-learn 1.1, released on May 13, 2022, adds quantile regression and target encoder for categorical variable encoding.

Main Features

Quantile regression

The QuantileRegressor estimates conditional quantiles rather than the mean, useful for prediction intervals.

python
from sklearn.linear_model import QuantileRegressor
import numpy as np

X = np.random.randn(200, 1)
y = 2 * X.ravel() + np.random.randn(200) * 0.5

# Quantile regression for the median
qr = QuantileRegressor(quantile=0.5)
qr.fit(X, y)
print(f'Coefficient: {qr.coef_[0]:.2f}')  # ~2.0

Target encoder

The TargetEncoder encodes categorical variables using the target variable mean, with regularization to prevent overfitting.

python
from sklearn.preprocessing import TargetEncoder
import numpy as np

X = np.array([['cat'], ['dog'], ['cat'], ['bird'], ['dog']])
y = np.array([1, 0, 1, 0, 1])

encoder = TargetEncoder()
X_encoded = encoder.fit_transform(X, y)
print(X_encoded.ravel())  # means per category

Sources