Skip to content

Commit b58fd06

Browse files
committed
chore: use air format
1 parent e7a1e07 commit b58fd06

38 files changed

+270
-141
lines changed

.Rbuildignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
^Meta$
1010
^README\.Rmd$
1111
^README\.html$
12+
^[\.]?air\.toml$
1213
^\.Renviron$
1314
^\.Rproj\.user$
1415
^\.ccache$

.pre-commit-config.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ repos:
44
- repo: https://github.com/lorenzwalthert/precommit
55
rev: v0.4.3.9008
66
hooks:
7-
- id: style-files
8-
args: [--style_pkg=styler.mlr, --style_fun=mlr_style]
9-
additional_dependencies:
10-
- mlr-org/styler.mlr
117
- id: roxygenize
128
additional_dependencies:
139
- ClusterR

R/LearnerClust.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
#' # get a specific learner from mlr_learners:
3131
#' learner = lrn("clust.kmeans")
3232
#' print(learner)
33-
LearnerClust = R6Class("LearnerClust",
33+
LearnerClust = R6Class(
34+
"LearnerClust",
3435
inherit = Learner,
3536
public = list(
3637
#' @field assignments (`NULL` | `vector()`)\cr

R/LearnerClustAffinityPropagation.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#' @export
2121
#' @template seealso_learner
2222
#' @template example
23-
LearnerClustAP = R6Class("LearnerClustAP",
23+
LearnerClustAP = R6Class(
24+
"LearnerClustAP",
2425
inherit = LearnerClust,
2526
public = list(
2627
#' @description

R/LearnerClustAgnes.R

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#' @export
1818
#' @template seealso_learner
1919
#' @template example
20-
LearnerClustAgnes = R6Class("LearnerClustAgnes",
20+
LearnerClustAgnes = R6Class(
21+
"LearnerClustAgnes",
2122
inherit = LearnerClust,
2223
public = list(
2324
#' @description
@@ -66,7 +67,8 @@ LearnerClustAgnes = R6Class("LearnerClustAgnes",
6667
private = list(
6768
.train = function(task) {
6869
pv = self$param_set$get_values(tags = "train")
69-
m = invoke(cluster::agnes,
70+
m = invoke(
71+
cluster::agnes,
7072
x = task$data(),
7173
diss = FALSE,
7274
.args = remove_named(pv, "k")

R/LearnerClustBICO.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#' @export
1616
#' @template seealso_learner
1717
#' @template example
18-
LearnerClustBICO = R6Class("LearnerClustBICO",
18+
LearnerClustBICO = R6Class(
19+
"LearnerClustBICO",
1920
inherit = LearnerClust,
2021
public = list(
2122
#' @description

R/LearnerClustBIRCH.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#' @export
1616
#' @template seealso_learner
1717
#' @template example
18-
LearnerClustBIRCH = R6Class("LearnerClustBIRCH",
18+
LearnerClustBIRCH = R6Class(
19+
"LearnerClustBIRCH",
1920
inherit = LearnerClust,
2021
public = list(
2122
#' @description

R/LearnerClustCMeans.R

+15-9
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,35 @@
1818
#' @export
1919
#' @template seealso_learner
2020
#' @template example
21-
LearnerClustCMeans = R6Class("LearnerClustCMeans",
21+
LearnerClustCMeans = R6Class(
22+
"LearnerClustCMeans",
2223
inherit = LearnerClust,
2324
public = list(
2425
#' @description
2526
#' Creates a new instance of this [R6][R6::R6Class] class.
2627
initialize = function() {
2728
param_set = ps(
2829
centers = p_uty(
29-
tags = c("required", "train"), custom_check = check_centers
30+
tags = c("required", "train"),
31+
custom_check = check_centers
3032
),
3133
iter.max = p_int(1L, default = 100L, tags = "train"),
3234
verbose = p_lgl(default = FALSE, tags = "train"),
3335
dist = p_fct(levels = c("euclidean", "manhattan"), default = "euclidean", tags = "train"),
3436
method = p_fct(levels = c("cmeans", "ufcl"), default = "cmeans", tags = "train"),
3537
m = p_dbl(1, default = 2, tags = "train"),
3638
rate.par = p_dbl(0, 1, tags = "train", depends = quote(method == "ufcl")),
37-
weights = p_uty(default = 1L, tags = "train", custom_check = crate(function(x) {
38-
if (test_numeric(x) && all(x > 0) || check_count(x, positive = TRUE)) {
39-
TRUE
40-
} else {
41-
"`weights` must be positive numeric vector or a single positive number"
42-
}
43-
})),
39+
weights = p_uty(
40+
default = 1L,
41+
tags = "train",
42+
custom_check = crate(function(x) {
43+
if (test_numeric(x) && all(x > 0) || check_count(x, positive = TRUE)) {
44+
TRUE
45+
} else {
46+
"`weights` must be positive numeric vector or a single positive number"
47+
}
48+
})
49+
),
4450
control = p_uty(tags = "train")
4551
)
4652

R/LearnerClustCobweb.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#' @export
1717
#' @template seealso_learner
1818
#' @template example
19-
LearnerClustCobweb = R6Class("LearnerClustCobweb",
19+
LearnerClustCobweb = R6Class(
20+
"LearnerClustCobweb",
2021
inherit = LearnerClust,
2122
public = list(
2223
#' @description

R/LearnerClustDBSCAN.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#' @export
1616
#' @template seealso_learner
1717
#' @template example
18-
LearnerClustDBSCAN = R6Class("LearnerClustDBSCAN",
18+
LearnerClustDBSCAN = R6Class(
19+
"LearnerClustDBSCAN",
1920
inherit = LearnerClust,
2021
public = list(
2122
#' @description

R/LearnerClustDBSCANfpc.R

+24-15
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#' @export
1616
#' @template seealso_learner
1717
#' @template example
18-
LearnerClustDBSCANfpc = R6Class("LearnerClustDBSCANfpc",
18+
LearnerClustDBSCANfpc = R6Class(
19+
"LearnerClustDBSCANfpc",
1920
inherit = LearnerClust,
2021
public = list(
2122
#' @description
@@ -27,20 +28,28 @@ LearnerClustDBSCANfpc = R6Class("LearnerClustDBSCANfpc",
2728
scale = p_lgl(default = FALSE, tags = "train"),
2829
method = p_fct(levels = c("hybrid", "raw", "dist"), tags = "train"),
2930
seeds = p_lgl(default = TRUE, tags = "train"),
30-
showplot = p_uty(default = FALSE, tags = "train", custom_check = crate(function(x) {
31-
if (test_flag(x) || test_int(x, lower = 0L, upper = 2L)) {
32-
TRUE
33-
} else {
34-
"`showplot` need to be either logical or integer between 0 and 2"
35-
}
36-
})),
37-
countmode = p_uty(default = NULL, tags = "train", custom_check = crate(function(x) {
38-
if (test_integer(x, null.ok = TRUE)) {
39-
TRUE
40-
} else {
41-
"`countmode` need to be NULL or vector of integers"
42-
}
43-
}))
31+
showplot = p_uty(
32+
default = FALSE,
33+
tags = "train",
34+
custom_check = crate(function(x) {
35+
if (test_flag(x) || test_int(x, lower = 0L, upper = 2L)) {
36+
TRUE
37+
} else {
38+
"`showplot` need to be either logical or integer between 0 and 2"
39+
}
40+
})
41+
),
42+
countmode = p_uty(
43+
default = NULL,
44+
tags = "train",
45+
custom_check = crate(function(x) {
46+
if (test_integer(x, null.ok = TRUE)) {
47+
TRUE
48+
} else {
49+
"`countmode` need to be NULL or vector of integers"
50+
}
51+
})
52+
)
4453
)
4554

4655
param_set$set_values(MinPts = 5L, scale = FALSE, seeds = TRUE, showplot = FALSE, countmode = NULL)

R/LearnerClustDiana.R

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#' @export
1818
#' @template seealso_learner
1919
#' @template example
20-
LearnerClustDiana = R6Class("LearnerClustDiana",
20+
LearnerClustDiana = R6Class(
21+
"LearnerClustDiana",
2122
inherit = LearnerClust,
2223
public = list(
2324
#' @description
@@ -47,7 +48,8 @@ LearnerClustDiana = R6Class("LearnerClustDiana",
4748
private = list(
4849
.train = function(task) {
4950
pv = self$param_set$get_values(tags = "train")
50-
m = invoke(cluster::diana,
51+
m = invoke(
52+
cluster::diana,
5153
x = task$data(),
5254
diss = FALSE,
5355
.args = remove_named(pv, "k")

R/LearnerClustEM.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#' @export
1818
#' @template seealso_learner
1919
#' @template example
20-
LearnerClustEM = R6Class("LearnerClustEM",
20+
LearnerClustEM = R6Class(
21+
"LearnerClustEM",
2122
inherit = LearnerClust,
2223
public = list(
2324
#' @description

R/LearnerClustFanny.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#' @export
2121
#' @template seealso_learner
2222
#' @template example
23-
LearnerClustFanny = R6Class("LearnerClustFanny",
23+
LearnerClustFanny = R6Class(
24+
"LearnerClustFanny",
2425
inherit = LearnerClust,
2526
public = list(
2627
#' @description

R/LearnerClustFarthestFirst.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#' @export
1717
#' @template seealso_learner
1818
#' @template example
19-
LearnerClustFarthestFirst = R6Class("LearnerClustFF",
19+
LearnerClustFarthestFirst = R6Class(
20+
"LearnerClustFF",
2021
inherit = LearnerClust,
2122
public = list(
2223
#' @description

R/LearnerClustFeatureless.R

+10-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#' @export
1313
#' @template seealso_learner
1414
#' @template example
15-
LearnerClustFeatureless = R6Class("LearnerClustFeatureless",
15+
LearnerClustFeatureless = R6Class(
16+
"LearnerClustFeatureless",
1617
inherit = LearnerClust,
1718
public = list(
1819
#' @description
@@ -68,11 +69,14 @@ LearnerClustFeatureless = R6Class("LearnerClustFeatureless",
6869

6970
# reorder rows so that the max probability corresponds to
7071
# the selected partition in `partition`
71-
prob = do.call(rbind, map(seq_along(partition), function(i) {
72-
x = prob[i, , drop = TRUE]
73-
pos = which_max(x)
74-
if (pos == i) x else append(x[-pos], x[pos], after = partition[i] - 1L)
75-
}))
72+
prob = do.call(
73+
rbind,
74+
map(seq_along(partition), function(i) {
75+
x = prob[i, , drop = TRUE]
76+
pos = which_max(x)
77+
if (pos == i) x else append(x[-pos], x[pos], after = partition[i] - 1L)
78+
})
79+
)
7680
}
7781

7882
PredictionClust$new(task = task, partition = partition, prob = prob)

R/LearnerClustHDBSCAN.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#' @export
1616
#' @template seealso_learner
1717
#' @template example
18-
LearnerClustHDBSCAN = R6Class("LearnerClustHDBSCAN",
18+
LearnerClustHDBSCAN = R6Class(
19+
"LearnerClustHDBSCAN",
1920
inherit = LearnerClust,
2021
public = list(
2122
#' @description

R/LearnerClustHclust.R

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#' @export
1616
#' @template seealso_learner
1717
#' @template example
18-
LearnerClustHclust = R6Class("LearnerClustHclust",
18+
LearnerClustHclust = R6Class(
19+
"LearnerClustHclust",
1920
inherit = LearnerClust,
2021
public = list(
2122
#' @description
@@ -56,12 +57,14 @@ LearnerClustHclust = R6Class("LearnerClustHclust",
5657
private = list(
5758
.train = function(task) {
5859
pv = self$param_set$get_values(tags = "train")
59-
dist = invoke(stats::dist,
60+
dist = invoke(
61+
stats::dist,
6062
x = task$data(),
6163
method = pv$d %??% "euclidean",
6264
.args = self$param_set$get_values(tags = c("train", "dist"))
6365
)
64-
m = invoke(stats::hclust,
66+
m = invoke(
67+
stats::hclust,
6568
d = dist,
6669
.args = self$param_set$get_values(tags = c("train", "hclust"))
6770
)

R/LearnerClustKKMeans.R

+13-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
#' @export
2020
#' @template seealso_learner
2121
#' @template example
22-
LearnerClustKKMeans = R6Class("LearnerClustKKMeans",
22+
LearnerClustKKMeans = R6Class(
23+
"LearnerClustKKMeans",
2324
inherit = LearnerClust,
2425
public = list(
2526
#' @description
@@ -33,10 +34,15 @@ LearnerClustKKMeans = R6Class("LearnerClustKKMeans",
3334
tags = "train"
3435
),
3536
sigma = p_dbl(
36-
0, tags = "train", depends = quote(kernel %in% c("rbfdot", "anovadot", "besseldot", "laplacedot"))
37+
0,
38+
tags = "train",
39+
depends = quote(kernel %in% c("rbfdot", "anovadot", "besseldot", "laplacedot"))
3740
),
3841
degree = p_int(
39-
1L, default = 3L, tags = "train", depends = quote(kernel %in% c("polydot", "anovadot", "besseldot"))
42+
1L,
43+
default = 3L,
44+
tags = "train",
45+
depends = quote(kernel %in% c("polydot", "anovadot", "besseldot"))
4046
),
4147
scale = p_dbl(0, default = 1, tags = "train", depends = quote(kernel %in% c("polydot", "tanhdot"))),
4248
offset = p_dbl(default = 1, tags = "train", depends = quote(kernel %in% c("polydot", "tanhdot"))),
@@ -83,11 +89,13 @@ LearnerClustKKMeans = R6Class("LearnerClustKKMeans",
8389
# kernel product between each new datapoint and itself: rows are identical
8490
d_xx = matrix(
8591
rep(diag(kernlab::kernelMatrix(K, as.matrix(data))), each = ncol(d_xc)),
86-
ncol = ncol(d_xc), byrow = TRUE
92+
ncol = ncol(d_xc),
93+
byrow = TRUE
8794
)
8895
# kernel product between each center and itself: columns are identical
8996
d_cc = matrix(
90-
rep(diag(kernlab::kernelMatrix(K, as.matrix(c))), each = nrow(d_xc)), nrow = nrow(d_xc)
97+
rep(diag(kernlab::kernelMatrix(K, as.matrix(c))), each = nrow(d_xc)),
98+
nrow = nrow(d_xc)
9199
)
92100
# this is the squared kernel distance to the centers
93101
d2 = d_xx + d_cc - 2 * d_xc

R/LearnerClustKMeans.R

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
#' @export
1919
#' @template seealso_learner
2020
#' @template example
21-
LearnerClustKMeans = R6Class("LearnerClustKMeans",
21+
LearnerClustKMeans = R6Class(
22+
"LearnerClustKMeans",
2223
inherit = LearnerClust,
2324
public = list(
2425
#' @description
@@ -28,7 +29,9 @@ LearnerClustKMeans = R6Class("LearnerClustKMeans",
2829
centers = p_uty(tags = c("required", "train"), custom_check = check_centers),
2930
iter.max = p_int(1L, default = 10L, tags = "train"),
3031
algorithm = p_fct(
31-
levels = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen"), default = "Hartigan-Wong", tags = "train"
32+
levels = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen"),
33+
default = "Hartigan-Wong",
34+
tags = "train"
3235
),
3336
nstart = p_int(1L, default = 1L, tags = "train"),
3437
trace = p_int(0L, default = 0L, tags = "train")

R/LearnerClustMclust.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#' @export
1717
#' @template seealso_learner
1818
#' @template example
19-
LearnerClustMclust = R6Class("LearnerClustMclust",
19+
LearnerClustMclust = R6Class(
20+
"LearnerClustMclust",
2021
inherit = LearnerClust,
2122
public = list(
2223
#' @description

0 commit comments

Comments
 (0)