pub fn density_based_cluster_validity<F, S1, S2, D>(
x: &ArrayBase<S1, Ix2>,
labels: &ArrayBase<S2, D>,
k: Option<usize>,
) -> Result<F>Expand description
Calculate Density-Based Cluster Validity (DBCV) index
The DBCV index measures the validity of a clustering based on the relative density of clusters. It accounts for variations in cluster densities and shapes. Values closer to 1 indicate better clustering.
§Arguments
x- Array of shape (n_samples, n_features) - The datalabels- Array of shape (n_samples,) - Predicted labels for each samplek- Number of neighbors to consider for density calculation (default: 5)
§Returns
- DBCV index value (between -1 and 1)
§Examples
use scirs2_core::ndarray::{array, Array2};
use scirs2_metrics::clustering::density::density_based_cluster_validity;
// Create a simple dataset with 2 clusters
let x = Array2::from_shape_vec((6, 2), vec![
1.0, 2.0, 1.5, 1.8, 1.2, 2.2,
5.0, 6.0, 5.2, 5.8, 5.5, 6.2,
]).unwrap();
let labels = array![0, 0, 0, 1, 1, 1];
let dbcv = density_based_cluster_validity(&x, &labels, None).unwrap();