8000 ENH sparse support in DBSCAN · scikit-learn/scikit-learn@0d8141e · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 0d8141e

Browse files
committed
ENH sparse support in DBSCAN
1 parent deb8ca8 commit 0d8141e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sklearn/cluster/dbscan_.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from ..base import BaseEstimator, ClusterMixin
1414
from ..metrics import pairwise_distances
15-
from ..utils import check_random_state
15+
from ..utils import check_random_state, check_array
1616
from ..neighbors import NearestNeighbors
1717

1818

@@ -83,7 +83,7 @@ def dbscan(X, eps=0.5, min_samples=5, metric='minkowski',
8383
if not eps > 0.0:
8484
raise ValueError("eps must be positive.")
8585

86-
X = np.asarray(X)
86+
X = check_array(X, accept_sparse='csr')
8787

8888
# If index order not given, create random order.
8989
random_state = check_random_state(random_state)
@@ -211,7 +211,7 @@ def fit(self, X):
211211
params: dict
212212
Overwrite keywords from __init__.
213213
"""
214-
X = np.asarray(X)
214+
X = check_array(X, accept_sparse='csr')
215215
clust = dbscan(X, **self.get_params())
216216
self.core_sample_indices_, self.labels_ = clust
217217
self.components_ = X[self.core_sample_indices_].copy()

0 commit comments

Comments
 (0)
0