cohen_kappa_score overflows integers #8354

Closed
chanansh opened this Issue Feb 14, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@chanansh

chanansh commented Feb 14, 2017

Description

cohen_kappa_score function returns number outside the range [-1,1] when input is long due to overflow when computing the outer product.

Steps/Code to Reproduce

from sklearn.metrics import cohen_kappa_score
y1 = np.random.randint(0, 3, 250000)
y2 = np.random.randint(0, 3, 250000)
cohen_kappa_score(y1,y2)

5.2202007721167556

Expected Results

Answer should be around 0, for example:

from sklearn.metrics import cohen_kappa_score
y1 = np.random.randint(0, 3, 2500)
y2 = np.random.randint(0, 3, 2500)
cohen_kappa_score(y1,y2)

-0.0023930258880147104

Actual Results

5.2202007721167556

Versions

Windows-10-10.0.14393-SP0
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]
NumPy 1.11.3
SciPy 0.18.1
Scikit-Learn 0.18.1

@chanansh

This comment has been minimized.

Show comment
Hide comment

related to #7929

@jnothman

This comment has been minimized.

Show comment
Hide comment
@jnothman

jnothman Feb 14, 2017

Member
Member

jnothman commented Feb 14, 2017

@chanansh

This comment has been minimized.

Show comment
Hide comment
@chanansh

chanansh Feb 14, 2017

Hi @jnothman, yeah np.int64 solves this.

Hi @jnothman, yeah np.int64 solves this.

@amueller amueller added the Bug label Mar 3, 2017

@jnothman

This comment has been minimized.

Show comment
Hide comment
@jnothman

jnothman Jun 19, 2017

Member

Fixed by #8094

Member

jnothman commented Jun 19, 2017

Fixed by #8094

@jnothman jnothman closed this Jun 19, 2017

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