From a3ee842dcf62fb63937e417269b7365f052d594f Mon Sep 17 00:00:00 2001 From: Maximilian Muecke Date: Tue, 19 Mar 2024 11:28:28 +0100 Subject: [PATCH] docs(readme): dynamic count of learners and measures in readme --- README.Rmd | 39 +++++++++++++++++++-------------------- README.md | 48 ++++++++++++++++++++++++------------------------ 2 files changed, 43 insertions(+), 44 deletions(-) diff --git a/README.Rmd b/README.Rmd index 15dd750d..04b1f986 100644 --- a/README.Rmd +++ b/README.Rmd @@ -11,7 +11,11 @@ knitr::opts_chunk$set( fig.path = "man/figures/README-", out.width = "100%" ) + library(mlr3cluster) +library(mlr3misc) +lrn_clust = as.data.table(mlr3::mlr_learners)[task_type == "clust", .(key, label, packages)] +msr_clust = as.data.table(mlr3::mlr_measures)[task_type == "clust", .(key, label, packages)] ``` # mlr3cluster @@ -48,8 +52,8 @@ pak::pak("mlr-org/mlr3cluster") The current version of **mlr3cluster** contains: -- A selection of 22 clustering learners that represent a wide variety of clusterers: partitional, hierarchical, fuzzy, etc. -- A selection of 4 performance measures +- A selection of `r nrow(lrn_clust)` clustering learners that represent a wide variety of clusterers: partitional, hierarchical, fuzzy, etc. +- A selection of `r nrow(msr_clust)` performance measures - Two built-in tasks to get started with clustering Also, the package is integrated with **[mlr3viz](https://github.com/mlr-org/mlr3viz)** which enables you to create great visualizations with just one line of code! @@ -59,35 +63,30 @@ Also, the package is integrated with **[mlr3viz](https://github.com/mlr-org/mlr3 ### Cluster Learners ```{r, echo = FALSE} -cran_pkgs = function(pkgs) { - mlr3misc::map_chr(pkgs, function(pkg) { - ii = if (length(pkg) > 2L) 3L else 2L - pkg = pkg[ii] - if (pkg == "stats") { - "[stats](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/stats-package.html)" - } else { - sprintf("[%1$s](https://cran.r-project.org/package=%1$s)", pkg) - } - }) +cran_pkg = function(pkgs) { + pkgs = ifelse( + pkgs %in% c("stats", "graphics", "datasets"), pkgs, sprintf("[%1$s](https://cran.r-project.org/package=%1$s)", pkgs) + ) + toString(pkgs) } -content = as.data.table(mlr3::mlr_learners, objects = TRUE)[task_type == "clust", .(key, label, packages)] -content[, `:=`( +lrn_clust[, packages := map(packages, function(x) setdiff(x, c("mlr3", "mlr3cluster")))] +lrn_clust[, `:=`( key = sprintf("[%1$s](https://mlr3cluster.mlr-org.com/reference/mlr_learners_%1$s)", key), - packages = cran_pkgs(packages) + packages = map_chr(packages, cran_pkg) )] -knitr::kable(content, format = "markdown", col.names = tools::toTitleCase(names(content))) +knitr::kable(lrn_clust, format = "markdown", col.names = tools::toTitleCase(names(lrn_clust))) ``` ### Cluster Measures ```{r, echo = FALSE} -content = as.data.table(mlr3::mlr_measures, objects = TRUE)[task_type == "clust", .(key, label, packages)] -content[, `:=`( +msr_clust[, packages := map(packages, function(x) setdiff(x, c("mlr3", "mlr3cluster")))] +msr_clust[, `:=`( key = sprintf("[%1$s](https://mlr3cluster.mlr-org.com/reference/mlr_measures_%1$s)", key), - packages = cran_pkgs(packages) + packages = map_chr(packages, cran_pkg) )] -knitr::kable(content, format = "markdown", col.names = tools::toTitleCase(names(content))) +knitr::kable(msr_clust, format = "markdown", col.names = tools::toTitleCase(names(msr_clust))) ``` diff --git a/README.md b/README.md index 01bb2646..625f1704 100644 --- a/README.md +++ b/README.md @@ -54,30 +54,30 @@ create great visualizations with just one line of code! ### Cluster Learners -| Key | Label | Packages | -|:------------------------------------------------------------------------------------------------|:--------------------------------------|:-------------------------------------------------------------------------------------| -| [clust.MBatchKMeans](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.MBatchKMeans) | Mini Batch K-Means | [ClusterR](https://cran.r-project.org/package=ClusterR) | -| [clust.SimpleKMeans](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.SimpleKMeans) | K-Means (Weka) | [RWeka](https://cran.r-project.org/package=RWeka) | -| [clust.agnes](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.agnes) | Agglomerative Hierarchical Clustering | [cluster](https://cran.r-project.org/package=cluster) | -| [clust.ap](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.ap) | Affinity Propagation Clustering | [apcluster](https://cran.r-project.org/package=apcluster) | -| [clust.cmeans](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.cmeans) | Fuzzy C-Means Clustering Learner | [e1071](https://cran.r-project.org/package=e1071) | -| [clust.cobweb](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.cobweb) | Cobweb Clustering | [RWeka](https://cran.r-project.org/package=RWeka) | -| [clust.dbscan](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.dbscan) | Density-Based Clustering | [dbscan](https://cran.r-project.org/package=dbscan) | -| [clust.dbscan_fpc](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.dbscan_fpc) | Density-Based Clustering with fpc | [fpc](https://cran.r-project.org/package=fpc) | -| [clust.diana](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.diana) | Divisive Hierarchical Clustering | [cluster](https://cran.r-project.org/package=cluster) | -| [clust.em](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.em) | Expectation-Maximization Clustering | [RWeka](https://cran.r-project.org/package=RWeka) | -| [clust.fanny](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.fanny) | Fuzzy Analysis Clustering | [cluster](https://cran.r-project.org/package=cluster) | -| [clust.featureless](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.featureless) | Featureless Clustering | [mlr3cluster](https://cran.r-project.org/package=mlr3cluster) | -| [clust.ff](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.ff) | Farthest First Clustering | [RWeka](https://cran.r-project.org/package=RWeka) | -| [clust.hclust](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.hclust) | Agglomerative Hierarchical Clustering | [stats](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/stats-package.html) | -| [clust.hdbscan](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.hdbscan) | HDBSCAN Clustering | [dbscan](https://cran.r-project.org/package=dbscan) | -| [clust.kkmeans](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.kkmeans) | Kernel K-Means | [kernlab](https://cran.r-project.org/package=kernlab) | -| [clust.kmeans](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.kmeans) | K-Means | [stats](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/stats-package.html) | -| [clust.mclust](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.mclust) | Gaussian Mixture Models Clustering | [mclust](https://cran.r-project.org/package=mclust) | -| [clust.meanshift](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.meanshift) | Mean Shift Clustering | [LPCM](https://cran.r-project.org/package=LPCM) | -| [clust.optics](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.optics) | OPTICS Clustering | [dbscan](https://cran.r-project.org/package=dbscan) | -| [clust.pam](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.pam) | Partitioning Around Medoids | [cluster](https://cran.r-project.org/package=cluster) | -| [clust.xmeans](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.xmeans) | X-means | [RWeka](https://cran.r-project.org/package=RWeka) | +| Key | Label | Packages | +|:------------------------------------------------------------------------------------------------|:--------------------------------------|:----------------------------------------------------------| +| [clust.MBatchKMeans](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.MBatchKMeans) | Mini Batch K-Means | [ClusterR](https://cran.r-project.org/package=ClusterR) | +| [clust.SimpleKMeans](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.SimpleKMeans) | K-Means (Weka) | [RWeka](https://cran.r-project.org/package=RWeka) | +| [clust.agnes](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.agnes) | Agglomerative Hierarchical Clustering | [cluster](https://cran.r-project.org/package=cluster) | +| [clust.ap](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.ap) | Affinity Propagation Clustering | [apcluster](https://cran.r-project.org/package=apcluster) | +| [clust.cmeans](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.cmeans) | Fuzzy C-Means Clustering Learner | [e1071](https://cran.r-project.org/package=e1071) | +| [clust.cobweb](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.cobweb) | Cobweb Clustering | [RWeka](https://cran.r-project.org/package=RWeka) | +| [clust.dbscan](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.dbscan) | Density-Based Clustering | [dbscan](https://cran.r-project.org/package=dbscan) | +| [clust.dbscan_fpc](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.dbscan_fpc) | Density-Based Clustering with fpc | [fpc](https://cran.r-project.org/package=fpc) | +| [clust.diana](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.diana) | Divisive Hierarchical Clustering | [cluster](https://cran.r-project.org/package=cluster) | +| [clust.em](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.em) | Expectation-Maximization Clustering | [RWeka](https://cran.r-project.org/package=RWeka) | +| [clust.fanny](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.fanny) | Fuzzy Analysis Clustering | [cluster](https://cran.r-project.org/package=cluster) | +| [clust.featureless](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.featureless) | Featureless Clustering | | +| [clust.ff](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.ff) | Farthest First Clustering | [RWeka](https://cran.r-project.org/package=RWeka) | +| [clust.hclust](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.hclust) | Agglomerative Hierarchical Clustering | stats | +| [clust.hdbscan](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.hdbscan) | HDBSCAN Clustering | [dbscan](https://cran.r-project.org/package=dbscan) | +| [clust.kkmeans](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.kkmeans) | Kernel K-Means | [kernlab](https://cran.r-project.org/package=kernlab) | +| [clust.kmeans](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.kmeans) | K-Means | stats, [clue](https://cran.r-project.org/package=clue) | +| [clust.mclust](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.mclust) | Gaussian Mixture Models Clustering | [mclust](https://cran.r-project.org/package=mclust) | +| [clust.meanshift](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.meanshift) | Mean Shift Clustering | [LPCM](https://cran.r-project.org/package=LPCM) | +| [clust.optics](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.optics) | OPTICS Clustering | [dbscan](https://cran.r-project.org/package=dbscan) | +| [clust.pam](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.pam) | Partitioning Around Medoids | [cluster](https://cran.r-project.org/package=cluster) | +| [clust.xmeans](https://mlr3cluster.mlr-org.com/reference/mlr_learners_clust.xmeans) | X-means | [RWeka](https://cran.r-project.org/package=RWeka) | ### Cluster Measures