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

Code before:
#
# Array API support was also added to several metrics in :mod:`sklearn.metrics`
# module, see :ref:`array_api_supported` for more details.
#
# Please refer the :ref:`array API support<array_api>` page for instructions
# to use scikit-learn with array API compatible libraries such as PyTorch or CuPy.
# Note that array API support is still experimental and must be
# explicitly be enabled both in SciPy and scikit-learn to work properly.
#
# TODO do we want to write a snippet?
# - which estimators would we feature?
# - we don't have PyTorch in doc build for now ...
# - we don't have GPU in the doc build but we could show a snippet with numpy
#   and commented out code to switch to PyToch on GPU
# - alternative: show only highlighted code without executing it?
# - alternative: add link to Colab notebook?

# %%
# Free-threaded CPython 3.14 support
# ----------------------------------
#
# scikit-learn has support for free-threaded CPython, in particular
# free-threaded wheels are available for all of our supported platforms on Python
# 3.14.
#
# Free-threaded (also known as nogil) CPython is a version of CPython that aims at
# enabling efficient multi-threaded use cases by removing the Global Interpreter
# Lock (GIL).
#
# If you want to try out free-threaded Python, the recommendation is to use
# Python 3.14, that has fixed a number of issues compared to Python 3.13. Feel
# free to try free-threaded on your use case and report any issues!
#
# For more details about free-threaded CPython see `py-free-threading doc <https://py-free-threading.github.io>`_,
# in particular `how to install a free-threaded CPython <https://py-free-threading.github.io/installing_cpython/>`_
# and `Ecosystem compatibility tracking <https://py-free-threading.github.io/tracking/>`_.
#
# The long term goal of free-threaded Python is to more efficiently leverage
# multi-core CPUs by using thread workers instead of subprocess workers for parallel
# computation when passing `n_jobs>1` in functions or estimators.
# Efficiency gains are expected by removing the need for inter-process communication.
# Note however that process-based parallelism is still the default joblib backend at
# the time of writing. You can call `joblib.parallel_config(backend="threading")` to
# change the default backend to "threading". Be aware that properly testing that
# everything is running smoothly when doing so is still an ongoing effort and that
# there are open issues to fix before considering making this the default.

# %%
# Temperature scaling in `CalibratedClassifierCV`
# -----------------------------------------------
# Probability calibration of classifiers with temperature scaling is available in

Review comment (suggestion):
```suggestion
# Free-threaded (also known as nogil) CPython is a version of CPython that aims to enable
```

I think you "aim at" when you point a physical thing at something (the most frequent use probably being a weapon that you aim at your enemy). When it is a goal I think you "aim to" - The other athletes aimed to beat Femke Bol at the 400m hurdles by teaming up

(I didn't include the next line, but we need to change "enabling" to "enable" if we make this change)

Code after:
# :class:`linear_model.RidgeClassifierCV`, :class:`mixture.GaussianMixture` and
# :class:`calibration.CalibratedClassifierCV`.
#
# Array API support was also added to several metrics in :mod:`sklearn.metrics`
# module, see :ref:`array_api_supported` for more details.
#
# Please refer to the :ref:`array API support<array_api>` page for instructions
# to use scikit-learn with array API compatible libraries such as PyTorch or CuPy.
# Note: Array API support is experimental and must be explicitly enabled both
# in SciPy and scikit-learn.
#
# Here is an excerpt of using a feature engineering preprocessor on the CPU,
# followed by :class:`calibration.CalibratedClassifierCV`
# and :class:`linear_model.RidgeCV` together on a GPU with the help of PyTorch:
#
# .. code-block:: python
#
#     ridge_pipeline_gpu = make_pipeline(
#         # Ensure that all features (including categorical features) are preprocessed
#         # on the CPU and mapped to a numerical representation.
#         feature_preprocessor,
#         # Move the results to the GPU and perform computations there
#         FunctionTransformer(
#             lambda x: torch.tensor(x.to_numpy().astype(np.float32), device="cuda"))
#         ,
#         CalibratedClassifierCV(
#             RidgeClassifierCV(alphas=alphas), method="temperature"
#         ),
#     )
#     with sklearn.config_context(array_api_dispatch=True):
#         cv_results = cross_validate(ridge_pipeline_gpu, features, target)
#
#
# See the `full notebook on Google Colab
# <https://colab.research.google.com/drive/1ztH8gUPv31hSjEeR_8pw20qShTwViGRx?usp=sharing>`_
# for more details. On this particular example, using the Colab GPU vs using a
# single CPU core leads to a 10x speedup which is quite typical for such workloads.

# %%
# Free-threaded CPython 3.14 support
# ----------------------------------
#
# scikit-learn has support for free-threaded CPython, in particular
# free-threaded wheels are available for all of our supported platforms on Python
# 3.14.
#
# We would be very interested by user feedback. Here are a few things you can
# try:
#
# - install free-threaded CPython 3.14, run your favourite
#   scikit-learn script and check that nothing breaks unexpectedly.