Skip to content

Bi-/coclustering API prevents scalability #2484

Closed as not planned
Closed as not planned

Description

@larsmans

The biclustering and coclustering estimators promise to store boolean arrays rows_ and columns_, of size n_clusters * n_samples and n_clusters * n_features, respectively, and convert these to indices only on demand. For use with large, sparse matrices and large numbers of clusters, these should be arrays of indices rather than boolean masks.

Activity

  1. larsmans commented on Sep 30, 2013

    @larsmans
    MemberAuthor
  2. kemaleren commented on Oct 2, 2013

    @kemaleren
    Contributor

    I'll take care of it. It should not require too much work, I think.

  3. kaushik94 commented on Mar 19, 2014

    @kaushik94
    Contributor

    Hi,

    Correct me if im wrong, instead of implementing a 2d array each for rows_ and columns_ , they must be 1d arrays each with rows_[i] and columns_[i] containing the index of the cluster it belongs to right ?

  4. jnothman commented on Mar 19, 2014

    @jnothman
    Member

    According to the documentation, SpectralBiclustering will assign each row (sample) and column (feature) to multiple clusters. So unless the number of clusters per sample and feature is fixed for a particular problem, it's difficult to store the data as an array, except if boolean.

    Storing this as a sparse indicator matrix may be appropriate.

  5. kaushik94 commented on Mar 19, 2014

    @kaushik94
    Contributor

    So you mean to say the rows_ and columns_ should be converted to sparse ?

  6. jnothman commented on Mar 19, 2014

    @jnothman
    Member

    Well, they should be stored sparsely at least, which is what "1d arrays each with rows_[i] and columns_[i] containing the index of the cluster it belongs to" would be doing anyway. Using a sparse matrix just provides an array-like interface to query "is feature i in cluster j?" or "what features are in cluster j?" or "what clusters is feature i in?".

  7. kaushik94 commented on Mar 19, 2014

    @kaushik94
    Contributor

    Yes I understood, do you have any sparse formats in mind ?
    What I feel is, we can't have a single best sparse matrix(like CSR, CSC) to support all the 3 types of queries with same efficiency. One of them will be less efficient(just my 2 cents). But a sparse structure will definitely enhance the performance, just want to know if there is a very efficient sparse format for this

  8. jnothman commented on Mar 19, 2014

    @jnothman
    Member

    Sure. Seeing as all the methods currently available work through get_indices which gets "row and column indices of the ith bicluster", that should suggest the answer.

  9. jnothman commented on Mar 19, 2014

    @jnothman
    Member

    Or choose the one that's easiest to construct. I don't know the code well enough.

  10. kaushik94 commented on Mar 19, 2014

    @kaushik94
    Contributor

    Yup right, CSR matrices, i would like to open a WIP on this one

    On Wed, Mar 19, 2014 at 8:03 AM, jnothman [email protected] wrote:

    Sure. Seeing as all the methods currently available work through
    get_indices which gets "row and column indices of the ith bicluster",
    that should suggest the answer.

    Reply to this email directly or view it on GitHubhttps://github.com//issues/2484#issuecomment-38012005
    .

  11. larsmans commented on Mar 19, 2014

    @larsmans
    MemberAuthor

    It doesn't have to be CSR. Two 2-d arrays of indices would suffice, I think. If these are kept in sorted order, get_indices can be done with at most four binary searches.

  12. jnothman commented on Mar 19, 2014

    @jnothman
    Member

    Sorry, I misunderstood a docstring comment and thought that this may actually assign multiple clusters to each cluster. It's only single cluster assignment.

    There are already simple assignment vectors, {column,row}_labels_. The attributes we're talking about redundantly store an indicator matrix, so that it's slightly easier to get back indices...

    I don't understand your code snippet (what is rows? where is cluster used? search column 0 of rows?), but perhaps a list of arrays will suffice... If this data must be stored redundantly, at least it should be easy to use.

  13. larsmans commented on Mar 19, 2014

    @larsmans
    MemberAuthor

    Never mind, that code is irrelevant if clusters are singly assigned to each point. We just need to store two arrays of indices.

    The code can easily be changed by putting in a simple transformation. Then, the implementation won't scale terribly well but at least we fixed the API to make optimizations possible.

  14. jnothman commented on Jul 22, 2014

    @jnothman
    Member

    I note that the biclustering metric as implemented operates over the rows_ and columns_ rather than {row,column}_labels_ structures. So if we no longer materialise those structures, evaluation needs to change to be over the unbinarized representation, or to handle either.

  15. jnothman commented on Aug 18, 2014

    @jnothman
    Member

    I just noticed that for the existing spectral biclustering implementations, rows_ and columns_ indicator matrices are not correctly documented. They each have n_col_clusters * n_row_clusters rows, not n_col_clusters or n_row_clusters alone: one is tiled, the other repeated. This seems a strange data format.

    Is there any reason we need to keep this indicator format? @kemaleren?

  16. jnothman commented on Aug 18, 2014

    @jnothman
    Member

    I note also that make_bicluster's row and column indicators have 3 rows for n_clusters=3 and make_checkerboard with the same parameters generates 9-row indicators!

  17. kemaleren commented on Aug 18, 2014

    @kemaleren
    Contributor

    @jnothman SpectralCoclustering and SpectralBiclustering have different bicluster semantics. In SpectralCoclustering, each row and each column are members of exactly one bicluster. In SpectralBiclustering, each row is a member of every column cluster, and vice versa, so the number of biclusters is the product of the number of row and column clusters.

    make_biclusters() follows the semantics of SpectralCoclustering, so n_clusters=3 is shorthand for 3 row clusters and 3 column clusters, thus 3 biclusters total.

    make_checkerboard() follows the semantics of SpectralBiclustering, so n_clusters=3 is shorthand for 9 biclusters total. You can also give it a tuple, so n_clusters=(3, 4) means 3 row clusters, 4 column clusters, and 12 biclusters.

  18. jnothman commented on Aug 18, 2014

    @jnothman
    Member

    I think this needs to be more explicit in the documentation, and certainly
    in the docstrings.

    On 19 August 2014 06:48, Kemal Eren [email protected] wrote:

    @jnothman https://github.com/jnothman SpectralCoclustering and
    SpectralBiclustering have different bicluster semantics. In
    SpectralCoclustering, each row and each column are members of exactly one
    bicluster. In SpectralBiclustering, each row is a member of every column
    cluster, and vice versa, so the number of biclusters is the product of the
    number of row and column clusters.

    make_biclusters() follows the semantics of SpectralCoclustering, so
    n_clusters=3 is shorthand for 3 row clusters and 3 column clusters, thus
    3 biclusters total.

    make_checkerboard() follows the semantics of SpectralBiclustering, so
    n_clusters=3 is shorthand for 9 biclusters total. You can also give it a
    tuple, so `n_clusters=(3, 4) means 3 row clusters, 4 column clusters, and
    12 biclusters.

    —
    Reply to this email directly or view it on GitHub
    #2484 (comment)
    .

  19. larsmans commented on Sep 4, 2014

    @larsmans
    MemberAuthor

    I'm not sure yet if this is the same problem, but I just tried running the bicluster_newsgroups.py example and I killed it after ~fifteen minutes, when it has done 5/20 iterations of bicluster_ncut. The function itself is entirely vectorized, and still it's still dead slow.

  20. larsmans commented on Sep 4, 2014

    @larsmans
    MemberAuthor

    Profiling with kernprof shows that

        cut = (X[row_complement[:, np.newaxis], cols].sum() +
               X[rows[:, np.newaxis], col_complement].sum())

    are taking up 92.5% of the time in this function (but I only ran the function for two iterations, which took 14min with profiling on).

    I must admit I don't even understand what the function is doing. From the example docs, it seems to compute a "normalized cut" of something (?)

  21. added
    Needs Decision
    on Dec 14, 2020
  22. adrinjalali commented on Apr 17, 2024

    @adrinjalali
    Member

    Since we're not sure how often biclustering algorithms are used and we might deprecate them (#9608), adding features to them would be out of scope.

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

    EnhancementModerateNeeds Decisionmodule:cluster

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions