Thanks to visit codestin.com
Credit goes to github.com

Skip to content

check_estimator cannot validate SGDClassifier with log_loss #24025

Closed
@jaime-cespedes-sisniega

Description

Describe the bug

It just tried to use SGDClassifier with log_loss, but it fail some test when I try to validated it with check_estimator function.

Steps/Code to Reproduce

from sklearn.linear_model import SGDClassifier
from sklearn.utils.estimator_checks import check_estimator
estimator = SGDClassifier(loss="log_loss")
check_estimator(estimator=estimator)

Expected Results

No error is thrown.

Actual Results

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jaime/PycharmProjects/frouros/.venv/lib/python3.9/site-packages/sklearn/utils/estimator_checks.py", line 623, in check_estimator
    check(estimator)
  File "/home/jaime/PycharmProjects/frouros/.venv/lib/python3.9/site-packages/sklearn/utils/_testing.py", line 318, in wrapper
    return fn(*args, **kwargs)
  File "/home/jaime/PycharmProjects/frouros/.venv/lib/python3.9/site-packages/sklearn/utils/estimator_checks.py", line 3474, in check_decision_proba_consistency
    assert_array_equal(rankdata(a), rankdata(b))
  File "/home/jaime/PycharmProjects/frouros/.venv/lib/python3.9/site-packages/numpy/testing/_private/utils.py", line 934, in assert_array_equal
    assert_array_compare(operator.__eq__, x, y, err_msg=err_msg,
  File "/home/jaime/PycharmProjects/frouros/.venv/lib/python3.9/site-packages/numpy/testing/_private/utils.py", line 844, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not equal

Mismatched elements: 16 / 20 (80%)
Max absolute difference: 4.
Max relative difference: 4.
 x: array([ 5. ,  5. ,  5. , 16.5,  5. , 16.5, 16.5, 16.5,  5. ,  5. , 12. ,
        5. ,  5. , 16.5, 16.5, 16.5, 11. , 10. , 16.5,  5. ])
 y: array([ 8.,  4.,  7., 14.,  2., 15., 20., 19.,  5.,  6., 12.,  3.,  1.,
       17., 18., 13., 11., 10., 16.,  9.])

Versions

System:
    python: 3.9.13 (main, May 23 2022, 22:01:06)  [GCC 9.4.0]
executable: /home/jaime/PycharmProjects/frouros/.venv/bin/python3
   machine: Linux-5.14.0-1045-oem-x86_64-with-glibc2.31

Python dependencies:
      sklearn: 1.1.1
          pip: 22.1.2
   setuptools: 62.6.0
        numpy: 1.23.1
        scipy: 1.8.1
       Cython: None
       pandas: None
   matplotlib: 3.5.2
       joblib: 1.1.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: libgomp
       filepath: /home/jaime/PycharmProjects/frouros/.venv/lib/python3.9/site-packages/scikit_learn.libs/libgomp-a34b3233.so.1.0.0
        version: None
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /home/jaime/PycharmProjects/frouros/.venv/lib/python3.9/site-packages/numpy.libs/libopenblas64_p-r0-742d56dc.3.20.so
        version: 0.3.20
threading_layer: pthreads
   architecture: SkylakeX
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /home/jaime/PycharmProjects/frouros/.venv/lib/python3.9/site-packages/scipy.libs/libopenblasp-r0-8b9e111f.3.17.so
        version: 0.3.17
threading_layer: pthreads
   architecture: SkylakeX
    num_threads: 8

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions