Repository: scikit-learn/scikit-learn
File: examples/release_highlights/plot_release_highlights_1_8_0.py (Python)

Code before:
# temporary parameter `use_legacy_attributes`.

from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegressionCV

X, y = make_classification(n_classes=3, n_informative=4)
model = LogisticRegressionCV(
    use_legacy_attributes=True, l1_ratios=(0,), solver="newton-cholesky"
).fit(X, y)
model.C_  # ndarray of shape (3,), 3 times the same value
model = LogisticRegressionCV(
    use_legacy_attributes=False, l1_ratios=(0,), solver="newton-cholesky"
).fit(X, y)
model.C_  # single float

# %%
# A further deprecation is related to the `penalty` parameter in both
# `LogisticRegression` and `LogisticRegressionCV`. It is redundant because `C` together
# with `l1_ratio` for `LogisticRegression` and `l1_ratios` for `LogisticRegressionCV`
# contains the same information. Removing `penalty` can ease specifying grid search
# parameter spaces and provides a tidier API.

# %%
# HTML representation of estimators
# ---------------------------------
# The hyperparameters of estimators have been added to the HTML representation of
# estimators as a dropdown table. Non-default hyperparameters are highlighted in orange
# and hovering over the hyperparameter name shows its docstring description as a
# tooltip.

from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler

clf = make_pipeline(StandardScaler(), LogisticRegression(random_state=0, C=10))
clf

# In addition a copy button has been added to be able to easily copy the fully
# qualified name of each hyperparameter (as returned by `get_params`) which is
# particularly useful to set the parameter grid of `GridSearchCV` for instance
# for nested pipelines and column transformers.

# %%
# DecisionTreeRegressor with MAE
# ------------------------------
# TODO

# %%
# ClassicalMDS
# ------------
# Classical MDS, also known as "Principal Coordinates Analysis (PCoA)"

Review comment (suggestion):
I think that most of what these comments explain were already included in version 1.7. The part that is new is the docstring as tooltip and link to the website documentation of each parameter. 

I suggest to substitute lines 174-177 and 186-189 with something more like:

"_Hyperparameters in the dropdown table of the HTML representation now include links to the online documentation. Docstring descriptions are also shown as tooltips on hover. 
To view an example, click on LogisticRegression and then on Parameters below._ "


Code after:

import matplotlib.pyplot as plt

from sklearn.calibration import CalibrationDisplay

fig, axes = plt.subplots(
    figsize=(8, 4.5),
    ncols=3,
    sharey=True,
)
for i, c in enumerate(ts.classes_):
    CalibrationDisplay.from_predictions(
        y == c, clf.predict_proba(X)[:, i], name="Uncalibrated", ax=axes[i], marker="s"
    )
    CalibrationDisplay.from_predictions(
        y == c,
        ts.predict_proba(X)[:, i],
        name="Temperature scaling",
        ax=axes[i],
        marker="o",
    )
    CalibrationDisplay.from_predictions(
        y == c, sig.predict_proba(X)[:, i], name="Sigmoid", ax=axes[i], marker="v"
    )
    axes[i].set_title(f"Class {c}")
    axes[i].set_xlabel(None)
    axes[i].set_ylabel(None)
    axes[i].get_legend().remove()
fig.suptitle("Reliability Diagrams per Class")
fig.supxlabel("Mean Predicted Probability")
fig.supylabel("Fraction of Class")
fig.legend(*axes[0].get_legend_handles_labels(), loc=(0.72, 0.5))
plt.subplots_adjust(right=0.7)
_ = fig.show()

# %%
# Efficiency improvements in linear models
# ----------------------------------------
# The fit time has been massively reduced for squared error based estimators
# with L1 penalty: `ElasticNet`, `Lasso`, `MultiTaskElasticNet`,
# `MultiTaskLasso` and their CV variants. The fit time improvement is mainly
# achieved by **gap safe screening rules**. They enable the coordinate descent
# solver to set feature coefficients to zero early on and not look at them
# again. The stronger the L1 penalty the earlier features can be excluded from
# further updates.

from time import time

from sklearn.datasets import make_regression
from sklearn.linear_model import ElasticNetCV