spectral_clustering.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #pragma once
6 
7 #include <raft/core/device_coo_matrix.hpp>
8 #include <raft/core/device_mdspan.hpp>
9 #include <raft/core/resources.hpp>
10 
11 namespace ML {
12 namespace SpectralClustering {
13 
17 struct params {
23  int n_init;
27  float eigen_tol;
29  uint64_t seed;
30 };
31 
41 void fit_predict(raft::resources const& handle,
42  params config,
43  raft::device_matrix_view<float, int, raft::row_major> dataset,
44  raft::device_vector_view<int, int> labels);
45 
55 void fit_predict(raft::resources const& handle,
56  params config,
57  raft::device_coo_matrix_view<float, int, int, int> connectivity_graph,
58  raft::device_vector_view<int, int> labels);
59 
71 void fit_predict(raft::resources const& handle,
72  params config,
73  raft::device_vector_view<int, int> rows,
74  raft::device_vector_view<int, int> cols,
75  raft::device_vector_view<float, int> vals,
76  raft::device_vector_view<int, int> labels);
77 
78 } // namespace SpectralClustering
79 } // namespace ML
void fit_predict(raft::resources const &handle, params config, raft::device_matrix_view< float, int, raft::row_major > dataset, raft::device_vector_view< int, int > labels)
Perform spectral clustering on input dataset by constructing a k-nearest neighbors graph.
Definition: dbscan.hpp:18
Spectral clustering parameters.
Definition: spectral_clustering.hpp:17
int n_clusters
Number of clusters to find.
Definition: spectral_clustering.hpp:19
int n_init
Number of times to run k-means with different seeds.
Definition: spectral_clustering.hpp:23
int n_neighbors
Number of neighbors for kNN graph construction.
Definition: spectral_clustering.hpp:25
uint64_t seed
Random seed for reproducibility.
Definition: spectral_clustering.hpp:29
int n_components
Number of eigenvectors to use.
Definition: spectral_clustering.hpp:21
float eigen_tol
Tolerance for the eigensolver.
Definition: spectral_clustering.hpp:27