cohen_kappa_score overflows integers #8354

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

cohen_kappa_score overflows integers#8354

opened this issue Feb 14, 2017 · 4 comments
Labels

chanansh commented Feb 14, 2017 • edited

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 commented Feb 14, 2017

 related to #7929
mentioned this issue Feb 14, 2017

jnothman commented Feb 14, 2017

 Thanks. Are you able to test if patching your working copy with #8094 fixes this? … On 14 February 2017 at 20:41, Hanan Shteingart ***@***.***> wrote: related to #7929 <#7929> — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#8354 (comment)>, or mute the thread .

chanansh commented Feb 14, 2017

 Hi @jnothman, yeah np.int64 solves this.
added the label Mar 3, 2017

jnothman commented Jun 19, 2017

 Fixed by #8094
closed this Jun 19, 2017