BUG: sklearn/utils/multiclass.type_of_target inconsistent for similar inputs
See original GitHub issueDescription
sklearn/utils/multiclass.type_of_target(y)
returns different results for practically identical ‘y’ values when y
a list
and when y
is an numpy array
.
Steps/Code to Reproduce
from sklearn.utils import multiclass
import numpy as np
x = [[1, 1], [0, 1]]
y = np.asarray(x)
a = multiclass.type_of_target(x)
b = multiclass.type_of_target(y)
print(a, b)
assert a == b
Expected Results
‘multilabel-indicator, multilabel-indicator’ No assertion error
Actual Results
‘multiclass-multioutput, multilabel-indicator’ Throws assertion error
AssertionError
System Info
System:
python: 3.6.7rc2 (v3.6.7rc2:4893861ab5, Oct 13 2018, 05:25:29) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
executable: /Users/maxwellaladago/Documents/pub/sklearn-dev/venv/bin/python
machine: Darwin-18.7.0-x86_64-i386-64bit
Python deps:
pip: 19.2.2
setuptools: 39.1.0
sklearn: 0.22.dev0
numpy: 1.17.0
scipy: 1.3.1
Cython: 0.29.13
pandas: None
matplotlib: None
joblib: 0.13.2
Will you consider a PR for this? Also, can you clarify what is_multilable's
behaviour should be? The documentation says it Check if y is in a multilabel format
but it seems to be checking whether y
is a multi_label_indicator
except that y is not restricted to be either 0 or 1.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
sklearn.utils.multiclass.type_of_target
sklearn.utils.multiclass .type_of_target¶ · 'continuous': y is an array-like of floats that are not all integers, and is 1d or a column vector. ·...
Read more >Supported target types are: ('binary', 'multiclass') error with ...
when I call cross_val_score function from sklearn.model_selection. It looks like parameters types are not good. I have a: <class 'pandas.core.
Read more >Use Keras Deep Learning Models with Scikit-Learn in Python
It is a fully featured library for general machine learning and provides many useful utilities in developing deep learning models.
Read more >What's new — MNE 1.2.2 documentation
Fix bug in the .compute_psd() methods where the number of unaggregated Welch segments was wrongly computed for some inputs, leading to an ...
Read more >Glossary of Common Terms and API Elements
array-like. The most common data format for input to Scikit-learn estimators and functions, array-like is any type object for which.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In the sense that we always report the strictest matching type, yes it is correct.
Running the code above with the current version throws no error. If this is a duplicate of #7931 it has been fixed by #14865. I’m closing it.