-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Closed
Description
Description
calling type_of_target(y) with y being a sparse representation of a multiclass-multioutput variable crashes.
Steps/Code to Reproduce
import numpy as np
from sklearn.utils.multiclass import type_of_target
from scipy import sparse
xx = sparse.rand(10,3, density=.3)
xx = (xx*10).astype(int)
yy = (xx>0).astype(int)
data = {'xx':xx.toarray(), 'xx_sparse':xx, 'yy':yy.toarray(), 'yy_sparse':yy}
for k, v in data.items():
print('{} -> {}'.format(k, type_of_target(v)))Expected Results
$python /tmp/test_typeoftarget.py
xx -> multiclass-multioutput
xx_sparse -> unknown
yy -> multilabel-indicator
yy_sparse -> multilabel-indicatorActual Results
$ python /tmp/test_typeoftarget.py
xx -> multiclass-multioutput
Traceback (most recent call last):
File "/tmp/test_typeoftarget.py", line 12, in <module>
print('{} -> {}'.format(k, type_of_target(v)))
File "/home/sik/miniconda3/lib/python3.6/site-packages/sklearn/utils/multiclass.py", line 267, in type_of_target
if y.ndim > 2 or (y.dtype == object and len(y) and
TypeError: len() of unsized object####Notes
#9059 solves it, but I need to double check that its actually properly solved / tested. Because this should had been captured by some test already.
Metadata
Metadata
Assignees
Labels
No labels