Spectral

View as Markdown

Source header: cuvs/cluster/spectral.hpp

Spectral Clustering Parameters

cluster::spectral::params

Parameters for spectral clustering

1struct params { ... };

Fields

NameTypeDescription
n_clustersintNumber of clusters to find
n_componentsintNumber of eigenvectors to use for the spectral embedding (typically equal to n_clusters)
n_initintNumber of k-means runs with different centroid seeds
n_neighborsintNumber of nearest neighbors for constructing the connectivity graph
tolerancefloatTolerance for the eigenvalue solver
rng_stateraft::random::RngStateRandom number generator state for reproducibility

Spectral Clustering

cluster::spectral::fit_predict

Perform spectral clustering on a connectivity graph

1void fit_predict(raft::resources const& handle,
2params config,
3raft::device_coo_matrix_view<float, int, int, int> connectivity_graph,
4raft::device_vector_view<int, int> labels);

n_clusters-1)

Parameters

NameDirectionTypeDescription
handleinraft::resources const&RAFT resource handle
configinparamsSpectral clustering parameters
connectivity_graphinraft::device_coo_matrix_view<float, int, int, int>Sparse COO matrix representing connectivity between data points
labelsoutraft::device_vector_view<int, int>Device vector of size n_samples to store cluster assignments (0 to

Returns

void

Additional overload: cluster::spectral::fit_predict

Perform spectral clustering on a connectivity graph

1void fit_predict(raft::resources const& handle,
2params config,
3raft::device_coo_matrix_view<double, int, int, int> connectivity_graph,
4raft::device_vector_view<int, int> labels);

n_clusters-1)

Parameters

NameDirectionTypeDescription
handleinraft::resources const&RAFT resource handle
configinparamsSpectral clustering parameters
connectivity_graphinraft::device_coo_matrix_view<double, int, int, int>Sparse COO matrix representing connectivity between data points
labelsoutraft::device_vector_view<int, int>Device vector of size n_samples to store cluster assignments (0 to

Returns

void

Additional overload: cluster::spectral::fit_predict

Perform spectral clustering on a dense dataset

1void fit_predict(raft::resources const& handle,
2params config,
3raft::device_matrix_view<float, int, raft::row_major> dataset,
4raft::device_vector_view<int, int> labels);

This overload automatically constructs the connectivity graph from the input dataset using k-nearest neighbors.

n_clusters-1)

Parameters

NameDirectionTypeDescription
handleinraft::resources const&RAFT resource handle
configinparamsSpectral clustering parameters
datasetinraft::device_matrix_view<float, int, raft::row_major>Dense row-major matrix of shape (n_samples, n_features)
labelsoutraft::device_vector_view<int, int>Device vector of size n_samples to store cluster assignments (0 to

Returns

void