Overview
Scikit-learn 1.0, released on September 25, 2021, is the first stable major version. It adds feature name support and enforces keyword-only parameters.
Main Features
Feature names
Transformers and estimators now preserve column names through the feature_names_in_ attribute and the get_feature_names_out() method.
python
import pandas as pd
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline
df = pd.DataFrame({
'age': [25, 30, 35],
'salary': [30000, 45000, 55000],
})
scaler = StandardScaler()
scaler.fit(df)
# Feature names preserved
print(scaler.feature_names_in_) # ['age', 'salary']
print(scaler.get_feature_names_out()) # ['age', 'salary']
Keyword-only parameters
Estimator constructor parameters become keyword-only, preventing ambiguous positional calls and improving code readability.
python
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import cross_val_score
import numpy as np
# Required keyword-only parameters
clf = RandomForestClassifier(
n_estimators=100,
max_depth=5,
random_state=42,
)
X = np.random.randn(100, 4)
y = (X[:, 0] > 0).astype(int)
scores = cross_val_score(clf, X, y, cv=5)
print(f'Mean score: {scores.mean():.3f}')
