Reference¶
Top-level package for Shared Nearest Neighbors.
-
class
shared_nearest_neighbors.
SNN
(n_neighbors=7, eps=5, min_samples=5, algorithm='auto', leaf_size=30, metric='euclidean', p=None, metric_params=None, dissimilarity_func=<function snn_dissimilarity_func>, n_jobs=None)[source]¶ -
fit
(X, y=None, sample_weight=None)[source]¶ Perform SNN clustering from features or distance matrix
First calls NearestNeighbors to construct the neighborhood graph considering the params n_neighbors, n_jobs, algorithm, leaf_size, metric, p, metric_params
Parameters: - X ({array-like, sparse matrix} of shape (n_samples, n_features), or (n_samples, n_samples)) – Training instances to cluster, or distances between instances if
metric='precomputed'
. If a sparse matrix is provided, it will be converted into a sparsecsr_matrix
. - y (Ignored) – Not used, present here for API consistency by convention.
- sample_weight (array-like of shape (n_samples,), default=None) – Weight of each sample, such that a sample with a weight of at least
min_samples
is by itself a core sample; a sample with a negative weight may inhibit its eps-neighbor from being core. Note that weights are absolute, and default to 1.
Returns: self – Returns a fitted instance of self.
Return type: object
- X ({array-like, sparse matrix} of shape (n_samples, n_features), or (n_samples, n_samples)) – Training instances to cluster, or distances between instances if
-
neighborhood_dissimilarity_matrix
(X) → scipy.sparse.csr.csr_matrix[source]¶ Neighborhood similarity matrix
Computes the sparse neighborhood similarity matrix
Parameters: X ({array-like, sparse matrix} of shape (n_samples, n_features), or (n_samples, n_samples)) – Training instances to cluster, or distances between instances if metric='precomputed'
. If a sparse matrix is provided, it will be converted into a sparsecsr_matrix
.Returns: Sparse matrix of shape (n_samples, n_samples) Return type: csr_matrix
-