Skip to content

LabelBinarizer returns dense output when input has only a single label even when sparse_output is set to True #6202

Closed

Description

@MechCoder
lb = LabelBinarizer(sparse_output=True)
y = [1, 1, 1, 1, 1]
lb.fit_transform(y)
array([[0],
   [0],
   [0],
   [0],
   [0]])

Activity

  1. changed the title [-]LabelBinarizer returns dense output when input has only a single label sparse_output is set to True[/-] [+]LabelBinarizer returns dense output when input has only a single label even when sparse_output is set to True[/+] on Jan 20, 2016
  2. added a commit that references this issue on Jan 21, 2016
  3. devashishd12 commented on Jan 22, 2016

    @devashishd12
    Contributor

    @MechCoder can I try this? In the case of len(classes)==1 it never checks for sparse_output so I tried adding a condition there but as expected it will return a (5,1) empty sparse array in this case. What kind of output is desired for this? Should I append a 0 or 1 to classes and pass it down?

  4. MechCoder commented on Jan 24, 2016

    @MechCoder
    MemberAuthor

    It seems even the dense case it is broken. IMO it should return a 1-D array with each sample encoded with pos_label

  5. added a commit that references this issue on Jan 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions