Skip to content

Instantly share code, notes, and snippets.

@m-Py
Last active October 13, 2020 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m-Py/597ccea1651685a79dc6673af48556de to your computer and use it in GitHub Desktop.
Save m-Py/597ccea1651685a79dc6673af48556de to your computer and use it in GitHub Desktop.
Test out the most recent version (v0.5.4) of anticlust
## 1. Load - and, if required, install - package `anticlust`
if (!requireNamespace("remotes")) {
install.packages("remotes")
}
remotes::install_github("m-Py/anticlust")
library(anticlust)
# Try out anticlustering - if there are no errors, everything is fine
# Optimize the cluster editing (diversity) criterion
anticlusters <- anticlustering(
schaper2019[, 3:6],
K = 3,
categories = schaper2019$room
)
anticlusters
# Use multiple starts of the algorithm to improve the objective and
# optimize the k-means criterion ("variance")
anticlusters <- anticlustering(
schaper2019[, 3:6],
objective = "variance",
K = 3,
categories = schaper2019$room,
method = "local-maximum",
repetitions = 2
)
anticlusters
# Optimize dispersion
anticlusters <- anticlustering(
dist(rnorm(100)),
objective = "dispersion",
K = 10
)
anticlusters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment