Skip to content

Commit

Permalink
docs(readme): dynamic count of learners and measures in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
m-muecke committed Mar 19, 2024
1 parent f59d5a5 commit a3ee842
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 44 deletions.
39 changes: 19 additions & 20 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!
Expand All @@ -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)))
```


Expand Down
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a3ee842

Please sign in to comment.