question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: sklearn/utils/multiclass.type_of_target inconsistent for similar inputs

See original GitHub issue

Description

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:closed
  • Created 4 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
jnothmancommented, Aug 17, 2019

In the sense that we always report the strictest matching type, yes it is correct.

0reactions
cmarmocommented, Mar 23, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found