Skip to content

Commit

Permalink
feat: migrate to paradox 1.0.0 depends
Browse files Browse the repository at this point in the history
  • Loading branch information
m-muecke committed Jun 11, 2024
1 parent 2566d13 commit fffc60a
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 56 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Imports:
data.table,
fpc,
mlr3misc (>= 0.10.0),
paradox (>= 0.10.0),
paradox (>= 1.0.0),
R6,
stats
Suggests:
Expand Down
27 changes: 14 additions & 13 deletions R/LearnerClustAgnes.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,22 @@ LearnerClustAgnes = R6Class("LearnerClustAgnes",
),
trace.lev = p_int(0L, default = 0L, tags = "train"),
k = p_int(1L, default = 2L, tags = "predict"),
par.method = p_uty(tags = "train", custom_check = crate(function(x) {
if (!(test_numeric(x) || test_list(x))) {
return("`par.method` needs to be a numeric vector")
}
if (length(x) %in% c(1L, 3L, 4L)) {
TRUE
} else {
"`par.method` needs be of length 1, 3, or 4"
}
}))
par.method = p_uty(
tags = "train",
depends = quote(method %in% c("flexible", "gaverage")),
custom_check = crate(function(x) {
if (!(test_numeric(x) || test_list(x))) {
return("`par.method` needs to be a numeric vector")
}
if (length(x) %in% c(1L, 3L, 4L)) {
TRUE
} else {
"`par.method` needs be of length 1, 3, or 4"
}
})
)
)

# param deps
param_set$add_dep("par.method", "method", CondAnyOf$new(c("flexible", "gaverage")))

param_set$set_values(k = 2L)

super$initialize(
Expand Down
4 changes: 1 addition & 3 deletions R/LearnerClustCMeans.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LearnerClustCMeans = R6Class("LearnerClustCMeans",
dist = p_fct(levels = c("euclidean", "manhattan"), default = "euclidean", tags = "train"),
method = p_fct(levels = c("cmeans", "ufcl"), default = "cmeans", tags = "train"),
m = p_dbl(1, default = 2, tags = "train"),
rate.par = p_dbl(0, 1, tags = "train"),
rate.par = p_dbl(0, 1, tags = "train", depends = quote(method == "ufcl")),
weights = p_uty(default = 1L, tags = "train", custom_check = crate(function(x) {
if (test_numeric(x) && all(x > 0) || check_count(x, positive = TRUE)) {
TRUE
Expand All @@ -43,8 +43,6 @@ LearnerClustCMeans = R6Class("LearnerClustCMeans",
})),
control = p_uty(tags = "train")
)
# add deps
param_set$add_dep("rate.par", "method", CondEqual$new("ufcl"))

param_set$set_values(centers = 2L)

Expand Down
10 changes: 5 additions & 5 deletions R/LearnerClustDBSCAN.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ LearnerClustDBSCAN = R6Class("LearnerClustDBSCAN",
borderPoints = p_lgl(default = TRUE, tags = "train"),
weights = p_uty(tags = "train", custom_check = check_numeric),
search = p_fct(levels = c("kdtree", "linear", "dist"), default = "kdtree", tags = "train"),
bucketSize = p_int(1L, default = 10L, tags = "train"),
bucketSize = p_int(1L, default = 10L, tags = "train", depends = quote(search == "kdtree")),
splitRule = p_fct(
levels = c("STD", "MIDPT", "FAIR", "SL_MIDPT", "SL_FAIR", "SUGGEST"), default = "SUGGEST", tags = "train"
levels = c("STD", "MIDPT", "FAIR", "SL_MIDPT", "SL_FAIR", "SUGGEST"),
default = "SUGGEST",
tags = "train",
depends = quote(search == "kdtree")
),
approx = p_dbl(default = 0, tags = "train")
)
# add deps
param_set$add_dep("bucketSize", "search", CondEqual$new("kdtree"))
param_set$add_dep("splitRule", "search", CondEqual$new("kdtree"))

super$initialize(
id = "clust.dbscan",
Expand Down
1 change: 1 addition & 0 deletions R/LearnerClustDiana.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ LearnerClustDiana = R6Class("LearnerClustDiana",
trace.lev = p_int(0L, default = 0L, tags = "train"),
k = p_int(1L, default = 2L, tags = "predict")
)

param_set$set_values(k = 2L)

super$initialize(
Expand Down
1 change: 1 addition & 0 deletions R/LearnerClustFanny.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ LearnerClustFanny = R6Class("LearnerClustFanny",
tol = p_dbl(0, default = 1e-15, tags = "train"),
trace.lev = p_int(0L, default = 0L, tags = "train")
)

param_set$set_values(k = 2L)

super$initialize(
Expand Down
4 changes: 1 addition & 3 deletions R/LearnerClustHclust.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ LearnerClustHclust = R6Class("LearnerClustHclust",
),
diag = p_lgl(default = FALSE, tags = c("train", "dist")),
upper = p_lgl(default = FALSE, tags = c("train", "dist")),
p = p_dbl(default = 2, tags = c("train", "dist")),
p = p_dbl(default = 2, tags = c("train", "dist"), depends = quote(distmethod == "minkowski")),
k = p_int(1L, default = 2L, tags = "predict")
)

# param deps
param_set$add_dep("p", "distmethod", CondAnyOf$new("minkowski"))
param_set$set_values(k = 2L, distmethod = "euclidean")

super$initialize(
Expand Down
22 changes: 10 additions & 12 deletions R/LearnerClustKKMeans.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,20 @@ LearnerClustKKMeans = R6Class("LearnerClustKKMeans",
levels = c("vanilladot", "polydot", "rbfdot", "tanhdot", "laplacedot", "besseldot", "anovadot", "splinedot"),
tags = "train"
),
sigma = p_dbl(0, tags = "train"),
degree = p_int(1L, default = 3L, tags = "train"),
scale = p_dbl(0, default = 1, tags = "train"),
offset = p_dbl(default = 1, tags = "train"),
order = p_int(default = 1L, tags = "train"),
sigma = p_dbl(
0, tags = "train", depends = quote(kernel %in% c("rbfdot", "anovadot", "besseldot", "laplacedot"))
),
degree = p_int(
1L, default = 3L, tags = "train", depends = quote(kernel %in% c("polydot", "anovadot", "besseldot"))
),
scale = p_dbl(0, default = 1, tags = "train", depends = quote(kernel %in% c("polydot", "tanhdot"))),
offset = p_dbl(default = 1, tags = "train", depends = quote(kernel %in% c("polydot", "tanhdot"))),
order = p_int(default = 1L, tags = "train", depends = quote(kernel == "besseldot")),
alg = p_fct(levels = c("kkmeans", "kerninghan"), default = "kkmeans", tags = "train"),
p = p_dbl(default = 1, tags = "train")
)
param_set$set_values(centers = 2L)

# add deps
param_set$add_dep("sigma", "kernel", CondAnyOf$new(c("rbfdot", "anovadot", "besseldot", "laplacedot")))
param_set$add_dep("degree", "kernel", CondAnyOf$new(c("polydot", "anovadot", "besseldot")))
param_set$add_dep("scale", "kernel", CondAnyOf$new(c("polydot", "tanhdot")))
param_set$add_dep("offset", "kernel", CondAnyOf$new(c("polydot", "tanhdot")))
param_set$add_dep("order", "kernel", CondEqual$new("besseldot"))
param_set$set_values(centers = 2L)

super$initialize(
id = "clust.kkmeans",
Expand Down
1 change: 1 addition & 0 deletions R/LearnerClustKMeans.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ LearnerClustKMeans = R6Class("LearnerClustKMeans",
nstart = p_int(1L, default = 1L, tags = "train"),
trace = p_int(0L, default = 0L, tags = "train")
)

param_set$set_values(centers = 2L)

super$initialize(
Expand Down
8 changes: 4 additions & 4 deletions R/LearnerClustMiniBatchKMeans.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ LearnerClustMiniBatchKMeans = R6Class("LearnerClustMiniBatchKMeans",
batch_size = p_int(1L, default = 10L, tags = "train"),
num_init = p_int(1L, default = 1L, tags = "train"),
max_iters = p_int(1L, default = 100L, tags = "train"),
init_fraction = p_dbl(0, 1, default = 1, tags = "train"),
init_fraction = p_dbl(
0, 1, default = 1, tags = "train", depends = quote(initializer %in% c("kmeans++", "optimal_init"))
),
initializer = p_fct(
levels = c("optimal_init", "quantile_init", "kmeans++", "random"), default = "kmeans++", tags = "train"
),
Expand All @@ -41,10 +43,8 @@ LearnerClustMiniBatchKMeans = R6Class("LearnerClustMiniBatchKMeans",
tol_optimal_init = p_dbl(0, default = 0.3, tags = "train"),
seed = p_int(default = 1L, tags = "train")
)
param_set$set_values(clusters = 2L)

# add deps
param_set$add_dep("init_fraction", "initializer", CondAnyOf$new(c("kmeans++", "optimal_init")))
param_set$set_values(clusters = 2L)

super$initialize(
id = "clust.MBatchKMeans",
Expand Down
10 changes: 5 additions & 5 deletions R/LearnerClustOPTICS.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ LearnerClustOPTICS = R6Class("LearnerClustOPTICS",
eps = p_dbl(0, special_vals = list(NULL), default = NULL, tags = "train"),
minPts = p_int(0L, default = 5L, tags = "train"),
search = p_fct(levels = c("kdtree", "linear", "dist"), default = "kdtree", tags = "train"),
bucketSize = p_int(1L, default = 10L, tags = "train"),
bucketSize = p_int(1L, default = 10L, tags = "train", depends = quote(search == "kdtree")),
splitRule = p_fct(
levels = c("STD", "MIDPT", "FAIR", "SL_MIDPT", "SL_FAIR", "SUGGEST"), default = "SUGGEST", tags = "train"
levels = c("STD", "MIDPT", "FAIR", "SL_MIDPT", "SL_FAIR", "SUGGEST"),
default = "SUGGEST",
tags = "train",
depends = quote(search == "kdtree")
),
approx = p_dbl(default = 0, tags = "train"),
eps_cl = p_dbl(0, tags = c("required", "train"))
)
# add deps
param_set$add_dep("bucketSize", "search", CondEqual$new("kdtree"))
param_set$add_dep("splitRule", "search", CondEqual$new("kdtree"))

super$initialize(
id = "clust.optics",
Expand Down
1 change: 1 addition & 0 deletions R/LearnerClustPAM.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ LearnerClustPAM = R6Class("LearnerClustPAM",
pamonce = p_int(0L, 5L, default = 0L, tags = "train"),
trace.lev = p_int(0L, default = 0L, tags = "train")
)

param_set$set_values(k = 2L)

super$initialize(
Expand Down
2 changes: 1 addition & 1 deletion man/mlr_learners_clust.MBatchKMeans.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/mlr_learners_clust.SimpleKMeans.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/mlr_learners_clust.cmeans.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/mlr_learners_clust.dbscan_fpc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/mlr_learners_clust.hclust.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/mlr_learners_clust.mclust.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/mlr_learners_clust.pam.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/mlr_learners_clust.xmeans.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fffc60a

Please sign in to comment.