Skip to content

Improve TruncatedSVD.transform on sparse csc matrices #16828

Closed

Description

@lorentzenchr

Describe the workflow you want to enable

import scipy.sparse as ss
from sklearn.decomposition import TruncatedSVD

X = ss.random(1000, 100, format='csc')
tsvd = TruncatedSVD().fit(X)

tsvd.transform(X)

Currently, in the last line, transform(X) will first convert X from csc to csr and then apply a dot product. I think this conversion is unnecessary, costs additional time, and one should better rely on scipy.sparse (or safe_sparse_dot) to convert if necessary.

Describe your proposed solution

Allow csc in

X = check_array(X, accept_sparse='csr')

Additional context

A PR with a benchmark result might be nice.

Activity

  1. added
    good first issue
    Easy
    on Apr 2, 2020
  2. shivamgargsya commented on Apr 2, 2020

    @shivamgargsya
    Contributor

    Can work on this.

  3. PandaTinker commented on Apr 4, 2020

    @PandaTinker
    Contributor

    It has been 2 days since this issue was raised so I added my PR and benchmark. This is my first commit and I have tried to follow the guidelines as much as I could. Please let me know if there are any places I need to fix.

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

    EasyNew Featuregood first issuehelp wantedmodule:decomposition

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions