Why am I getting 32 bit response for confusion_matrix when all the inputs are 64 bit? #7929

Closed
simonm3 opened this Issue Nov 24, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@simonm3

simonm3 commented Nov 24, 2016

I have a sample of 1m rows and the cohen_kappa_score showed as -11.3 when it should be -1 to +1. Further investigation showed that the confusion matrix returns a 32 bit result and in cohen_kappa calculation the outer product overflows.

Here is an example with a small amount of data. If I put np.int64 around the confusion matrix then it works.

import sys
from sklearn.metrics import confusion_matrix
y1 = np.int64([1,0,0,1])
y2 = np.int64([0,0,1,1])
confusion = confusion_matrix(y1, y2)
sys.version, type(y1[0]), type(y2[0]), type(confusion[0,0])

('3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]',
numpy.int64,
numpy.int64,
numpy.int32)

@jnothman

This comment has been minimized.

Show comment
Hide comment
@jnothman

jnothman Nov 24, 2016

Member
Member

jnothman commented Nov 24, 2016

@simonm3

This comment has been minimized.

Show comment
Hide comment
@simonm3

simonm3 Nov 24, 2016

simonm3 commented Nov 24, 2016

@jnothman

This comment has been minimized.

Show comment
Hide comment
@jnothman

jnothman Nov 24, 2016

Member
Member

jnothman commented Nov 24, 2016

@lesteve

This comment has been minimized.

Show comment
Hide comment
@lesteve

lesteve Dec 1, 2016

Member

Why is the default int 32 bit when I am running a 64 bit machine?

For the record this happens only on Windows, on my Linux box, np.iinfo(int) is int64. I always wondered what is the point of using np.int to be honest instead of an explicit np.int32 or np.int64. @jnothman I am interested if you have any hints about that.

Member

lesteve commented Dec 1, 2016

Why is the default int 32 bit when I am running a 64 bit machine?

For the record this happens only on Windows, on my Linux box, np.iinfo(int) is int64. I always wondered what is the point of using np.int to be honest instead of an explicit np.int32 or np.int64. @jnothman I am interested if you have any hints about that.

@amueller

This comment has been minimized.

Show comment
Hide comment
@amueller

amueller Mar 3, 2017

Member

@jnothman is this still open?

Member

amueller commented Mar 3, 2017

@jnothman is this still open?

@jnothman

This comment has been minimized.

Show comment
Hide comment
@jnothman

jnothman Mar 4, 2017

Member

Waiting for you or someone to review #8094

Member

jnothman commented Mar 4, 2017

Waiting for you or someone to review #8094

@jnothman jnothman closed this in #8094 Jun 19, 2017

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