Skip to contents

Determines optimal number of clusters (K) for k-means using elbow, silhouette, and gap statistic methods. Use for PUMA clustering diagnostics.

Usage

get_kmeans_opt_k(opts, method = "median")

Arguments

opts

list. Results of fviz_nbclust for each method.

method

character(1). Aggregation method ('median' or 'mean').

Value

integer(1). Optimal K value for clustering.

Details

  • Aggregates optimal K from multiple methods (median or mean).

  • Returns integer optimal K value for clustering.

  • Used for diagnostics and zone group selection.

Settings

None.

See also

scripts/weighting/zone_groups.R

Other clustering utilities: entropy_zone_groups(), kmeans_zone_groups(), spectral_zone_groups()

Examples

## Not run:
get_kmeans_opt_k(opts, method = 'median')
#> Error in get_kmeans_opt_k(opts, method = "median"): could not find function "get_kmeans_opt_k"