-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
README.Rmd
115 lines (83 loc) · 3.92 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
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
Package website: [release](https://mlr3cluster.mlr-org.com/) \| [dev](https://mlr3cluster.mlr-org.com/dev/)
Cluster analysis for **[mlr3](https://github.com/mlr-org/mlr3/)**.
<!-- badges: start -->
[![r-cmd-check](https://github.com/mlr-org/mlr3cluster/actions/workflows/r-cmd-check.yml/badge.svg)](https://github.com/mlr-org/mlr3cluster/actions/workflows/r-cmd-check.yml)
[![CRAN status](https://www.r-pkg.org/badges/version/mlr3cluster)](https://CRAN.R-project.org/package=mlr3cluster)
[![StackOverflow](https://img.shields.io/badge/stackoverflow-mlr3-orange.svg)](https://stackoverflow.com/questions/tagged/mlr3)
[![Mattermost](https://img.shields.io/badge/chat-mattermost-orange.svg)](https://lmmisld-lmu-stats-slds.srv.mwn.de/mlr_invite/)
<!-- badges: end -->
**mlr3cluster** is an extension package for cluster analysis within the **[mlr3](https://github.com/mlr-org/mlr3)** ecosystem. It is a successor of clustering capabilities of **[mlr2](https://github.com/mlr-org/mlr)**.
## Installation
Install the last release from CRAN:
```{r, eval = FALSE}
install.packages("mlr3cluster")
```
Install the development version from GitHub:
```{r, eval = FALSE}
# install.packages("pak")
pak::pak("mlr-org/mlr3cluster")
```
## Feature Overview
The current version of **mlr3cluster** contains:
- 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!
## Cluster Analysis
### Cluster Learners
```{r, echo = FALSE}
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)
}
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 = map_chr(packages, cran_pkg)
)]
knitr::kable(lrn_clust, format = "markdown", col.names = tools::toTitleCase(names(lrn_clust)))
```
### Cluster Measures
```{r, echo = FALSE}
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 = map_chr(packages, cran_pkg)
)]
knitr::kable(msr_clust, format = "markdown", col.names = tools::toTitleCase(names(msr_clust)))
```
## Example
```{r, eval = FALSE}
library(mlr3)
library(mlr3cluster)
task = tsk("usarrests")
learner = lrn("clust.kmeans")
learner$train(task)
prediction = learner$predict(task = task)
```
## More Resources
Check out the **[blogpost](https://www.r-bloggers.com/2020/10/introducing-mlr3cluster-cluster-analysis-package/)** for a more detailed introduction to the package.
Also, **[mlr3book](https://mlr3book.mlr-org.com/chapters/chapter13/beyond_regression_and_classification.html#sec-cluster)** has a section on clustering.
## Future Plans
- Add more learners and measures
- Integrate the package with **[mlr3pipelines](https://github.com/mlr-org/mlr3pipelines)** (work in progress)
If you have any questions, feedback or ideas, feel free to open an issue [here](https://github.com/mlr-org/mlr3cluster/issues).