8000 AffinityPropagation `fit` fails with sparse matrix input · Issue #4051 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
AffinityPropagation fit fails with sparse matrix input #4051
Closed
@tttthomasssss

Description

@tttthomasssss

Calling fit() or fit_predict() with a csr matrix as input crashes the code (when affinity != 'precomputed').

I've investigated the error a bit and found that X = np.asarray(X) in the fit method of affinity_propagation_.py is causing the error and should be replaced by sth like X = check_array(X, accept_sparse='csr') as is done for DBSCAN.

Note:
Just re-checked, the problem does not happen with the latest stable release (scikit-learn==0.15.2) as the problematic line X = np.asarray(X) is not in the fit() method.

Minimal example to reproduce the error:

from sklearn.cluster import AffinityPropagation
from sklearn.datasets import fetch_20newsgroups_vectorized

b = fetch_20newsgroups_vectorized()
affinity = AffinityPropagation()
affinity.fit(b.data)

Setup:
scikit-learn==0.16.dev0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0