find_elbow This function takes in unlabeled, scaled data and performs clustering using the KMeans clustering algorithm values of K up to the min(10, n_samples - 1). It returns the value for K which maximizes the mean silhouette scores across all clusters.

find_elbow(X)

Arguments

X

matrix: unlabeled data with appropriate preprocessing steps applied.

Value

numeric: The optimal choice of K in the K-means algorithm according to silhouette score.

Examples

X <- array(c(c(0, 1, 10, 10, 10, 10), c(0, 1, 10, 11, 0, 1)), dim = c(6,2)) X_scaled <- preprocess(X) optimal_K <- find_elbow(X_scaled)