Python/Sklearn: https://scikit-learn.org/stable/modules/clustering.html#clus...
R: https://cran.r-hub.io/web/packages/clusterCrit/clusterCrit.p...
You can also use some regularization criterion (AIC, BIC, or other)
Python/Sklearn: https://scikit-learn.org/stable/modules/clustering.html#clus...
R: https://cran.r-hub.io/web/packages/clusterCrit/clusterCrit.p...