.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/release_highlights/plot_release_highlights_1_7_0.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_release_highlights_plot_release_highlights_1_7_0.py: ======================================= Release Highlights for scikit-learn 1.7 ======================================= .. currentmodule:: sklearn We are pleased to announce the release of scikit-learn 1.7! Many bug fixes and improvements were added, as well as some key new features. Below we detail the highlights of this release. **For an exhaustive list of all the changes**, please refer to the :ref:`release notes `. To install the latest version (with pip):: pip install --upgrade scikit-learn or with conda:: conda install -c conda-forge scikit-learn .. GENERATED FROM PYTHON SOURCE LINES 25-35 Improved estimator's HTML representation ---------------------------------------- The HTML representation of estimators now includes a section containing the list of parameters and their values. Non-default parameters are highlighted in orange. A copy button is also available to copy the "fully-qualified" parameter name without the need to call the `get_params` method. It is particularly useful when defining a parameter grid for a grid-search or a randomized-search with a complex pipeline. See the example below and click on the different estimator's blocks to see the improved HTML representation. .. GENERATED FROM PYTHON SOURCE LINES 35-43 .. code-block:: Python from sklearn.linear_model import LogisticRegression from sklearn.pipeline import make_pipeline from sklearn.preprocessing import StandardScaler model = make_pipeline(StandardScaler(with_std=False), LogisticRegression(C=2.0)) model .. raw:: html
Pipeline(steps=[('standardscaler', StandardScaler(with_std=False)),
                    ('logisticregression', LogisticRegression(C=2.0))])
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.


.. GENERATED FROM PYTHON SOURCE LINES 44-52 Custom validation set for histogram-based Gradient Boosting estimators ---------------------------------------------------------------------- The :class:`ensemble.HistGradientBoostingClassifier` and :class:`ensemble.HistGradientBoostingRegressor` now support directly passing a custom validation set for early stopping to the `fit` method, using the `X_val`, `y_val`, and `sample_weight_val` parameters. In a :class:`pipeline.Pipeline`, the validation set `X_val` can be transformed along with `X` using the `transform_input` parameter. .. GENERATED FROM PYTHON SOURCE LINES 52-71 .. code-block:: Python import sklearn from sklearn.datasets import make_classification from sklearn.ensemble import HistGradientBoostingClassifier from sklearn.model_selection import train_test_split from sklearn.pipeline import Pipeline from sklearn.preprocessing import StandardScaler sklearn.set_config(enable_metadata_routing=True) X, y = make_classification(random_state=0) X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.2, random_state=0) clf = HistGradientBoostingClassifier() clf.set_fit_request(X_val=True, y_val=True) model = Pipeline([("sc", StandardScaler()), ("clf", clf)], transform_input=["X_val"]) model.fit(X, y, X_val=X_val, y_val=y_val) .. raw:: html
Pipeline(steps=[('sc', StandardScaler()),
                    ('clf', HistGradientBoostingClassifier())],
             transform_input=['X_val'])
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.


.. GENERATED FROM PYTHON SOURCE LINES 72-77 Plotting ROC curves from cross-validation results ------------------------------------------------- The class :class:`metrics.RocCurveDisplay` has a new class method `from_cv_results` that allows to easily plot multiple ROC curves from the results of :func:`model_selection.cross_validate`. .. GENERATED FROM PYTHON SOURCE LINES 77-88 .. code-block:: Python from sklearn.datasets import make_classification from sklearn.linear_model import LogisticRegression from sklearn.metrics import RocCurveDisplay from sklearn.model_selection import cross_validate X, y = make_classification(n_samples=150, random_state=0) clf = LogisticRegression(random_state=0) cv_results = cross_validate(clf, X, y, cv=5, return_estimator=True, return_indices=True) _ = RocCurveDisplay.from_cv_results(cv_results, X, y) .. image-sg:: /auto_examples/release_highlights/images/sphx_glr_plot_release_highlights_1_7_0_001.png :alt: plot release highlights 1 7 0 :srcset: /auto_examples/release_highlights/images/sphx_glr_plot_release_highlights_1_7_0_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 89-99 Array API support ----------------- Several functions have been updated to support array API compatible inputs since version 1.6, especially metrics from the :mod:`sklearn.metrics` module. In addition, it is no longer required to install the `array-api-compat` package to use the experimental array API support in scikit-learn. Please refer to the :ref:`array API support` page for instructions to use scikit-learn with array API compatible libraries such as PyTorch or CuPy. .. GENERATED FROM PYTHON SOURCE LINES 101-109 Improved API consistency of Multi-layer Perceptron -------------------------------------------------- The :class:`neural_network.MLPRegressor` has a new parameter `loss` and now supports the "poisson" loss in addition to the default "squared_error" loss. Moreover, the :class:`neural_network.MLPClassifier` and :class:`neural_network.MLPRegressor` estimators now support sample weights. These improvements have been made to improve the consistency of these estimators with regard to the other estimators in scikit-learn. .. GENERATED FROM PYTHON SOURCE LINES 111-116 Migration toward sparse arrays ------------------------------ In order to prepare `SciPy migration from sparse matrices to sparse arrays `_, all scikit-learn estimators that accept sparse matrices as input now also accept sparse arrays. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.183 seconds) .. _sphx_glr_download_auto_examples_release_highlights_plot_release_highlights_1_7_0.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/scikit-learn/scikit-learn/main?urlpath=lab/tree/notebooks/auto_examples/release_highlights/plot_release_highlights_1_7_0.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_release_highlights_1_7_0.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_release_highlights_1_7_0.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_release_highlights_1_7_0.zip ` .. include:: plot_release_highlights_1_7_0.recommendations .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_