8000 sklearn.metrics.precision_score gives 0.0 when class is 0 only · Issue #13453 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

sklearn.metrics.precision_score gives 0.0 when class is 0 only #13453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
EricSchles opened this issue Mar 15, 2019 · 1 comment
Closed

sklearn.metrics.precision_score gives 0.0 when class is 0 only #13453

EricSchles opened this issue Mar 15, 2019 · 1 comment

Comments

@EricSchles
Copy link
EricSchles commented Mar 15, 2019

Description

sklearn.metrics.precision_score gives 0.0 when class is 0 only.

Steps/Code to Reproduce

Example:

from sklearn import metrics

y = [0,0,0]
y_pred = [0,0,0]
print(metrics.precision_score(y, y_pred)) # returns 0.0

Expected Results

The expected result should be 1.0 because all the values are the same.

Actual Results

The actual result is 0.0

Versions

/usr/local/lib/python3.6/dist-packages/numpy/distutils/system_info.py:625: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
self.calc_info()
/usr/local/lib/python3.6/dist-packages/numpy/distutils/system_info.py:625: UserWarning:
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
self.calc_info()
/usr/local/lib/python3.6/dist-packages/numpy/distutils/system_info.py:625: UserWarning:
Blas (http://www.netlib.org/blas/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [blas_src]) or by setting
the BLAS_SRC environment variable.
self.calc_info()

System

python: 3.6.6 (default, Sep 12 2018, 18:26:19)  [GCC 8.0.1 20180414 (experimental) [trunk revision 
259383]]
executable: /usr/local/bin/python
machine: Linux-4.4.0-17763-Microsoft-x86_64-with-Ubuntu-18.04-bionic

BLAS

macros:
lib_dirs:
cblas_libs: cblas

Python deps

pip: 18.0
setuptools: 39.2.0
sklearn: 0.20.0
numpy: 1.15.2
scipy: 1.1.0
Cython: 0.28.3
pandas: 0.23.1

I would be happy to help fix this if folks want. For now, I'm just going to check if all values are zero and if they are, I'll return 1.0 Thanks!

@qinhanmin2014
Copy link
Member

We now raise UndefinedMetricWarning and return 0. There's not a clear definition of these edge cases, so we think it's OK to tell users our solution.
Duplicate of #10843

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0