For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
GitHubCUDA-X
    • Home
    • Installation
  • Getting Started
    • Introduction
    • Integrations
    • Use-cases
  • User Guide
    • API Guide
    • Benchmarking Guide
    • Field Guide
    • References
  • Developer Guide
    • Coding Guidelines
    • Contributing
  • API Reference
    • C API Documentation
    • Cpp API Documentation
      • Cluster Agglomerative
      • Cluster Kmeans
      • Cluster Spectral
      • Common Types
      • Distance Distance
      • Distance Grammian
      • Neighbors All Neighbors
      • Neighbors Ball Cover
      • Neighbors Brute Force
      • Neighbors Cagra
      • Neighbors Common
      • Neighbors Dynamic Batching
      • Neighbors Epsilon Neighborhood
      • Neighbors HNSW
      • Neighbors Composite Index
      • Neighbors IVF Flat
      • Neighbors IVF PQ
      • Neighbors IVF SQ
      • Neighbors NN Descent
      • Neighbors Refine
      • Neighbors Scann
      • Neighbors Tiered Index
      • Neighbors Vamana
      • Preprocessing Quantize Binary
      • Preprocessing PCA
      • Preprocessing Quantize PQ
      • Preprocessing Quantize Scalar
      • Preprocessing Spectral Embedding
      • Selection Select K
      • Stats Silhouette Score
      • Stats Trustworthiness Score
      • Util Cutlass Utils
      • Util File Io
    • Python API Documentation
    • Java API Documentation
    • Rust API Documentation
    • Go API Documentation
NVIDIANVIDIA
Developer-friendly docs for your API
Privacy Policy | Your Privacy Choices | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact

Copyright © 2026, NVIDIA Corporation.

LogoLogocuVS
GitHubCUDA-X
On this page
  • Silhouette Score
  • stats::silhouette_score
  • stats::silhouette_score_batched
API ReferenceCpp API Documentation

Silhouette Score

||View as Markdown|
Previous

Selection Select K

Next

Stats Trustworthiness Score

Source header: cuvs/stats/silhouette_score.hpp

Silhouette Score

stats::silhouette_score

main function that returns the average silhouette score for a given set of data and its clusterings

1float silhouette_score(
2raft::resources const& handle,
3raft::device_matrix_view<const float, int64_t, raft::row_major> X_in,
4raft::device_vector_view<const int, int64_t> labels,
5std::optional<raft::device_vector_view<float, int64_t>> silhouette_score_per_sample,
6int64_t n_unique_labels,
7cuvs::distance::DistanceType metric = cuvs::distance::DistanceType::L2Unexpanded);

Parameters

NameDirectionTypeDescription
handleinraft::resources const&raft handle for managing expensive resources
X_ininraft::device_matrix_view<const float, int64_t, raft::row_major>input matrix Data in row-major format (nRows x nCols)
labelsinraft::device_vector_view<const int, int64_t>the pointer to the array containing labels for every data sample (length: nRows)
silhouette_score_per_sampleoutstd::optional<raft::device_vector_view<float, int64_t>>optional array populated with the silhouette score for every sample (length: nRows)
n_unique_labelsinint64_tnumber of unique labels in the labels array
metricincuvs::distance::DistanceTypeDistance metric to use. Euclidean (L2) is used by default
Default: cuvs::distance::DistanceType::L2Unexpanded.

Returns

float

The silhouette score.

stats::silhouette_score_batched

function that returns the average silhouette score for a given set of data and its clusterings

1float silhouette_score_batched(
2raft::resources const& handle,
3raft::device_matrix_view<const float, int64_t, raft::row_major> X,
4raft::device_vector_view<const int, int64_t> labels,
5std::optional<raft::device_vector_view<float, int64_t>> silhouette_score_per_sample,
6int64_t n_unique_labels,
7int64_t batch_size,
8cuvs::distance::DistanceType metric = cuvs::distance::DistanceType::L2Unexpanded);

Parameters

NameDirectionTypeDescription
handleinraft::resources const&raft handle for managing expensive resources
Xinraft::device_matrix_view<const float, int64_t, raft::row_major>input matrix Data in row-major format (nRows x nCols)
labelsinraft::device_vector_view<const int, int64_t>the pointer to the array containing labels for every data sample (length: nRows)
silhouette_score_per_sampleoutstd::optional<raft::device_vector_view<float, int64_t>>optional array populated with the silhouette score for every sample (length: nRows)
n_unique_labelsinint64_tnumber of unique labels in the labels array
batch_sizeinint64_tnumber of samples per batch
metricincuvs::distance::DistanceTypethe numerical value that maps to the type of distance metric to be used in the calculations
Default: cuvs::distance::DistanceType::L2Unexpanded.

Returns

float

The silhouette score.

Additional overload: stats::silhouette_score

main function that returns the average silhouette score for a given set of data and its clusterings

1double silhouette_score(
2raft::resources const& handle,
3raft::device_matrix_view<const double, int64_t, raft::row_major> X_in,
4raft::device_vector_view<const int, int64_t> labels,
5std::optional<raft::device_vector_view<double, int64_t>> silhouette_score_per_sample,
6int64_t n_unique_labels,
7cuvs::distance::DistanceType metric = cuvs::distance::DistanceType::L2Unexpanded);

Parameters

NameDirectionTypeDescription
handleinraft::resources const&raft handle for managing expensive resources
X_ininraft::device_matrix_view<const double, int64_t, raft::row_major>input matrix Data in row-major format (nRows x nCols)
labelsinraft::device_vector_view<const int, int64_t>the pointer to the array containing labels for every data sample (length: nRows)
silhouette_score_per_sampleoutstd::optional<raft::device_vector_view<double, int64_t>>optional array populated with the silhouette score for every sample (length: nRows)
n_unique_labelsinint64_tnumber of unique labels in the labels array
metricincuvs::distance::DistanceTypethe numerical value that maps to the type of distance metric to be used in the calculations
Default: cuvs::distance::DistanceType::L2Unexpanded.

Returns

double

The silhouette score.

Additional overload: stats::silhouette_score_batched

function that returns the average silhouette score for a given set of data and its clusterings

1double silhouette_score_batched(
2raft::resources const& handle,
3raft::device_matrix_view<const double, int64_t, raft::row_major> X,
4raft::device_vector_view<const int, int64_t> labels,
5std::optional<raft::device_vector_view<double, int64_t>> silhouette_score_per_sample,
6int64_t n_unique_labels,
7int64_t batch_size,
8cuvs::distance::DistanceType metric = cuvs::distance::DistanceType::L2Unexpanded);

Parameters

NameDirectionTypeDescription
handleinraft::resources const&raft handle for managing expensive resources
Xinraft::device_matrix_view<const double, int64_t, raft::row_major>input matrix Data in row-major format (nRows x nCols)
labelsinraft::device_vector_view<const int, int64_t>the pointer to the array containing labels for every data sample (length: nRows)
silhouette_score_per_sampleoutstd::optional<raft::device_vector_view<double, int64_t>>optional array populated with the silhouette score for every sample (length: nRows)
n_unique_labelsinint64_tnumber of unique labels in the labels array
batch_sizeinint64_tnumber of samples per batch
metricincuvs::distance::DistanceTypethe numerical value that maps to the type of distance metric to be used in the calculations
Default: cuvs::distance::DistanceType::L2Unexpanded.

Returns

double

The silhouette score.