Skip to content

Deprecation warning of probA_/probB_ raised in _repr_mimebundle_ #34056

Closed

Description

@jcrist

Describe the bug and give evidence about its user-facing impact

With the upcoming deprecation of probability in SVC (and probA_/probB_), a deprecation warning is now raised in the repr within IPython/Jupyter notebooks, not just when accessed by the user.

Steps/Code to Reproduce

In [1]: from sklearn.svm import SVC
f
In [2]: from sklearn.datasets import make_classification

In [3]: X, y = make_classification()

In [4]: model = SVC(probability=True).fit(X, y)  # Warning here makes sense!
/home/jcristharif/miniforge3/envs/cuml-dev/lib/python3.14/site-packages/sklearn/svm/_base.py:239: FutureWarning: The `probability` parameter was deprecated in 1.9 and will be removed in version 1.11. Use `CalibratedClassifierCV(SVC(), ensemble=False)` instead of `SVC(probability=True)`
  warnings.warn(

In [5]: model  # but warning here is probably a bug
Out[5]: /home/jcristharif/miniforge3/envs/cuml-dev/lib/python3.14/site-packages/sklearn/utils/deprecation.py:109: FutureWarning: Attribute `probA_` was deprecated in version 1.9 and will be removed in 1.11 as the `probability=True` option for SVC and NuSVC was deprecated and will be removed in 1.11.
  warnings.warn(msg, category=FutureWarning)
/home/jcristharif/miniforge3/envs/cuml-dev/lib/python3.14/site-packages/sklearn/utils/deprecation.py:109: FutureWarning: Attribute `probB_` was deprecated in version 1.9 and will be removed in 1.11 as the `probability=True` option for SVC and NuSVC was deprecated and will be removed in 1.11.
  warnings.warn(msg, category=FutureWarning)
SVC(probability=True)

In [6]: model.probA_  # warning here also makes sense!
/home/jcristharif/miniforge3/envs/cuml-dev/lib/python3.14/site-packages/sklearn/utils/deprecation.py:109: FutureWarning: Attribute `probA_` was deprecated in version 1.9 and will be removed in 1.11 as the `probability=True` option for SVC and NuSVC was deprecated and will be removed in 1.11.
  warnings.warn(msg, category=FutureWarning)
Out[6]: array([-2.55286725])

Expected Results

No warning in fancy repr, just in actual usage.

Actual Results

N/A

Versions

System:
    python: 3.14.4 | packaged by conda-forge | (main, Apr  8 2026, 01:59:35) [GCC 14.3.0]
executable: /home/jcristharif/miniforge3/envs/cuml-dev/bin/python3.14
   machine: Linux-6.17.0-22-generic-x86_64-with-glibc2.39

Python dependencies:
      sklearn: 1.9.dev0
          pip: 26.1.1
   setuptools: 82.0.1
        numpy: 2.4.4
        scipy: 1.16.3
       Cython: 3.2.4
       pandas: 2.3.3
   matplotlib: 3.10.9
       joblib: 1.5.3
threadpoolctl: 3.6.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 64
         prefix: libopenblas
       filepath: /home/jcristharif/miniforge3/envs/cuml-dev/lib/libopenblasp-r0.3.33.so
        version: 0.3.33
threading_layer: pthreads
   architecture: Cooperlake

       user_api: openmp
   internal_api: openmp
    num_threads: 64
         prefix: libgomp
       filepath: /home/jcristharif/miniforge3/envs/cuml-dev/lib/python3.14/site-packages/scikit_learn.libs/libgomp-e985bcbb.so.1.0.0
        version: None

Interest in fixing the bug

I'm happy to push up a fix if this is a confirmed bug and not intentional.

Activity

  1. added
    Needs Triage
    on May 19, 2026
  2. removed
    Needs Triage
    on May 19, 2026
  3. jeremiedbb commented on May 19, 2026

    @jeremiedbb
    Member

    Thanks for the report @jcrist. I agree the repr of the model should not raise the warning. I guess we should filter the warnings out when listing the fitted attributes of the estimator (we missed that in #33399). I find it even more surprising for the regular repr since this one doesn't even display the fitted attributes.

    One thing that we could do in addition is to find a way to show that a given fitted attribute is deprecated. But that can be done later.

    @jcrist feel free to open a PR.

    cc/ @DeaMariaLeon

  4. added this to the 1.9 milestone on May 19, 2026
  5. DeaMariaLeon commented on May 20, 2026

    @DeaMariaLeon
    Member

    We can still see the HTML diagram with the code provided above. I thought that it was breaking before showing it when I first read it. So, this is what we get:
    Image

    If someone prints the model later (in a cell that is much below) in the notebook, wouldn't the warning be useful?

  6. DeaMariaLeon commented on May 20, 2026

    @DeaMariaLeon
    Member

    I forgot to say that it's fine with me if it's removed, I was just wondering.

  7. jeremiedbb commented on May 20, 2026

    @jeremiedbb
    Member

    To me, the warning should only happen if you explicitly access probA_.

  8. DeaMariaLeon commented on May 20, 2026

    @DeaMariaLeon
    Member

    Oh, I see. Thanks.

  9. jcrist commented on May 20, 2026

    @jcrist
    ContributorAuthor

    I've pushed up #34069 as a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions