Last active
June 15, 2022 22:10
-
-
Save mikemahoney218/6c32b554d84e3c13cd68c628928425ca to your computer and use it in GitHub Desktop.
Testing several clustering methods in spatial_clustering_cv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remotes::install_github('tidymodels/spatialsample') | |
library(spatialsample) | |
library(cluster) | |
make_clusters <- function(func) { | |
set.seed(123) | |
boston_canopy |> | |
spatial_clustering_cv(cluster_function = func) |> | |
autoplot() | |
} | |
function_list <- list( | |
"kmeans", | |
"hclust", | |
\(dists, v, ...) fanny(dists, v, maxit = 1e4)$clustering, | |
\(dists, v, ...) pam(dists, v)$clustering, | |
\(dists, v, ...) cutree(agnes(dists), v), | |
\(dists, v, ...) cutree(diana(dists), v) | |
) | |
lapply(function_list, make_clusters) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment