Skip to content
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

cohen_kappa_score overflows integers #8354

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

cohen_kappa_score overflows integers #8354

chanansh opened this issue Feb 14, 2017 · 4 comments
Labels
Bug

Comments

@chanansh
Copy link

@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
Copy link
Author

@chanansh chanansh commented Feb 14, 2017

related to #7929

@jnothman
Copy link
Member

@jnothman jnothman commented Feb 14, 2017

@chanansh
Copy link
Author

@chanansh chanansh commented Feb 14, 2017

Hi @jnothman, yeah np.int64 solves this.

@amueller amueller added the Bug label Mar 3, 2017
@jnothman
Copy link
Member

@jnothman 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.