>>> import numpy as np
>>> from sklearn.preprocessing import LabelBinarizer
>>> y = np.random.randint(0, 10, (1000,1))
>>> y
array([[7],
       [6],
       [2],
       [6],
[...]
>>> LabelBinarizer().fit_transform(y).shape # [1]
(1000, 1)
>>> LabelBinarizer().fit_transform(y.ravel()).shape
(1000, 10)
>>> LabelBinarizer().fit_transform(list(y)).shape
[...]
TypeError: unhashable type: 'numpy.ndarray'
>>> LabelBinarizer().fit_transform(list([list(a) for a in y])).shape # [2]
(1000, 10)

When `y` has shape (n_samples, 1), LabelBinarizer recognizes it as an
indicator matrix and return it as is... Lars, do you know what's the use
case for accepting indicator matrices in LabelBinarizer? (I don't
remember...) I would expect # [1] and # [2] to return the same thing.

Mathieu
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to