Skip to content

Commit 73a4fe6

Browse files
authored
Merge pull request #954 from mlr-org/namespace-prefix
chore: remove namespace prefix for mlr3misc, data.table, checkmate where applicable…
2 parents 5eab77d + 9a08c90 commit 73a4fe6

File tree

7 files changed

+26
-26
lines changed

7 files changed

+26
-26
lines changed

R/Graph.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,13 +383,13 @@ Graph = R6Class("Graph",
383383
extra_vertices = setdiff(ids, c(df$from, df$to))
384384

385385
all_names = unique(unlist(df))
386-
df = data.table::setDT(mlr3misc::map(df, function(x) match(x, all_names)))
386+
df = setDT(map(df, function(x) match(x, all_names)))
387387
gr = paste0(map(seq_len(nrow(df)), function(x) {
388388
paste0(df[x, ][[1L]], " -> ", df[x, ][[2L]])
389389
}), collapse = ";\n")
390390

391391
all_names = gsub("\\.", "_", all_names)
392-
labels = paste0(unlist(mlr3misc::map(unique(unlist(df)), function(x) {
392+
labels = paste0(unlist(map(unique(unlist(df)), function(x) {
393393
paste0(x, " [label=", '"', all_names[x], '"', ",fontsize=", fontsize, ']')
394394
})), collapse = ";\n")
395395
dot = paste0(gr, ";\n", labels)

R/PipeOp.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ check_types = function(self, data, direction, operation) {
536536
autoconverter = get_autoconverter(typereq)
537537
msg = ""
538538
if (!is.null(autoconverter)) {
539-
mlr3misc::require_namespaces(autoconverter$packages,
539+
require_namespaces(autoconverter$packages,
540540
sprintf("The following packages are required to convert object of class %s to class %s: %%s.", class(data_element)[1], typereq))
541541
msg = tryCatch({
542542
data_element = autoconverter$fun(data_element)

R/PipeOpNMF.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ PipeOpNMF = R6Class("PipeOpNMF",
166166
names(.args)[match("pbackend", names(.args), nomatch = 0L)] = ".pbackend"
167167
names(.args)[match("callback", names(.args), nomatch = 0L)] = ".callback"
168168

169-
nmf = mlr3misc::invoke(NMF::nmf,
169+
nmf = invoke(NMF::nmf,
170170
x = x,
171171
rng = NULL,
172172
model = NULL,
@@ -178,9 +178,9 @@ PipeOpNMF = R6Class("PipeOpNMF",
178178
self$state = structure(list(nmf = nmf), class = "PipeOpNMFstate")
179179

180180
# here we have two options? return directly h or do what we do during prediction
181-
#h = t(mlr3misc::invoke(NMF::coef, object = nmf))
182-
w = mlr3misc::invoke(NMF::basis, object = nmf)
183-
h_ = t(mlr3misc::invoke(MASS::ginv, X = w) %*% x)
181+
#h = t(invoke(NMF::coef, object = nmf))
182+
w = invoke(NMF::basis, object = nmf)
183+
h_ = t(invoke(MASS::ginv, X = w) %*% x)
184184
colnames(h_) = paste0("NMF", seq_len(self$param_set$values$rank))
185185
h_
186186
},
@@ -197,8 +197,8 @@ PipeOpNMF = R6Class("PipeOpNMF",
197197
}
198198

199199
x = t(as.matrix(dt))
200-
w = mlr3misc::invoke(NMF::basis, object = self$state$nmf)
201-
h_ = t(mlr3misc::invoke(MASS::ginv, X = w) %*% x)
200+
w = invoke(NMF::basis, object = self$state$nmf)
201+
h_ = t(invoke(MASS::ginv, X = w) %*% x)
202202
colnames(h_) = paste0("NMF", seq_len(self$param_set$values$rank))
203203
h_
204204
},

R/PipeOpVtreat.R

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ PipeOpVtreat = R6Class("PipeOpVtreat",
134134
initialize = function(id = "vtreat", param_vals = list()) {
135135
ps = ps(
136136
recommended = p_lgl(tags = c("train", "predict")),
137-
cols_to_copy = p_uty(custom_check = checkmate::check_function, tags = c("train", "predict")),
137+
cols_to_copy = p_uty(custom_check = check_function, tags = c("train", "predict")),
138138
# tags stand for: regression vtreat::regression_parameters() / classification vtreat::classification_parameters() / multinomial vtreat::multinomial_parameters()
139139
minFraction = p_dbl(lower = 0, upper = 1, default = 0.02, tags = c("train", "regression", "classification", "multinomial")),
140140
smFactor = p_dbl(lower = 0, upper = Inf, default = 0, tags = c("train", "regression", "classification", "multinomial")),
@@ -207,40 +207,40 @@ PipeOpVtreat = R6Class("PipeOpVtreat",
207207
}
208208

209209
if (length(self$param_set$values$imputation_map)) {
210-
checkmate::assert_subset(names(self$param_set$values$imputation_map), choices = var_list, empty.ok = TRUE)
210+
assert_subset(names(self$param_set$values$imputation_map), choices = var_list, empty.ok = TRUE)
211211
}
212212

213213
# FIXME: Handle non-Regr / non-Classif Tasks that inherit from TaskSupervised, #913
214214
task_type = task$task_type
215215
transform_design = if (task_type == "regr") {
216-
mlr3misc::invoke(vtreat::NumericOutcomeTreatment,
216+
invoke(vtreat::NumericOutcomeTreatment,
217217
var_list = var_list,
218218
outcome_name = task$target_names,
219219
cols_to_copy = self$param_set$values$cols_to_copy(task),
220-
params = vtreat::regression_parameters(mlr3misc::insert_named(self$param_set$get_values(tags = "regression"), list(check_for_duplicate_frames = FALSE))),
220+
params = vtreat::regression_parameters(insert_named(self$param_set$get_values(tags = "regression"), list(check_for_duplicate_frames = FALSE))),
221221
imputation_map = self$param_set$values$imputation_map)
222222
} else if (task_type == "classif") {
223223
if (length(task$class_names) > 2L) {
224-
mlr3misc::invoke(vtreat::MultinomialOutcomeTreatment,
224+
invoke(vtreat::MultinomialOutcomeTreatment,
225225
var_list = var_list,
226226
outcome_name = task$target_names,
227227
cols_to_copy = self$param_set$values$cols_to_copy(task),
228-
params = vtreat::multinomial_parameters(mlr3misc::insert_named(self$param_set$get_values(tags = "multinomial"), list(check_for_duplicate_frames = FALSE))),
228+
params = vtreat::multinomial_parameters(insert_named(self$param_set$get_values(tags = "multinomial"), list(check_for_duplicate_frames = FALSE))),
229229
imputation_map = self$param_set$values$imputation_map)
230230
} else {
231-
mlr3misc::invoke(vtreat::BinomialOutcomeTreatment,
231+
invoke(vtreat::BinomialOutcomeTreatment,
232232
var_list = var_list,
233233
outcome_name = task$target_names,
234234
outcome_target = task$positive,
235235
cols_to_copy = self$param_set$values$cols_to_copy(task),
236-
params = vtreat::classification_parameters(mlr3misc::insert_named(self$param_set$get_values(tags = "classification"), list(check_for_duplicate_frames = FALSE))),
236+
params = vtreat::classification_parameters(insert_named(self$param_set$get_values(tags = "classification"), list(check_for_duplicate_frames = FALSE))),
237237
imputation_map = self$param_set$values$imputation_map)
238238
}
239239
}
240240

241241
# the following exception handling is necessary because vtreat sometimes fails with "no usable vars" if the data is already "clean" enough
242242
vtreat_res = tryCatch(
243-
mlr3misc::invoke(vtreat::fit_prepare,
243+
invoke(vtreat::fit_prepare,
244244
vps = transform_design,
245245
dframe = task$data(),
246246
weights = if ("weights_learner" %in% names(task)) task$weights_learner$weight else task$weights$weight,
@@ -261,11 +261,11 @@ PipeOpVtreat = R6Class("PipeOpVtreat",
261261

262262
self$state$treatment_plan = vtreat_res$treatments
263263

264-
d_prepared = data.table::setDT(vtreat_res$cross_frame)
264+
d_prepared = setDT(vtreat_res$cross_frame)
265265

266266
feature_subset = self$state$treatment_plan$get_feature_names() # subset to vtreat features
267267
if (self$param_set$values$recommended) {
268-
score_frame = mlr3misc::invoke(vtreat::get_score_frame, vps = self$state$treatment_plan)
268+
score_frame = invoke(vtreat::get_score_frame, vps = self$state$treatment_plan)
269269
feature_subset = feature_subset[feature_subset %in% score_frame$varName[score_frame$recommended]] # subset to only recommended
270270
}
271271
feature_subset = c(feature_subset, self$param_set$values$cols_to_copy(task)) # respect cols_to_copy
@@ -283,7 +283,7 @@ PipeOpVtreat = R6Class("PipeOpVtreat",
283283

284284
# the following exception handling is necessary because vtreat sometimes fails with "no usable vars" if the data is already "clean" enough
285285
d_prepared = tryCatch(
286-
data.table::setDT(mlr3misc::invoke(vtreat::prepare,
286+
setDT(invoke(vtreat::prepare,
287287
treatmentplan = self$state$treatment_plan,
288288
dframe = task$data())),
289289
error = function(error_condition) {
@@ -297,7 +297,7 @@ PipeOpVtreat = R6Class("PipeOpVtreat",
297297

298298
feature_subset = self$state$treatment_plan$get_feature_names() # subset to vtreat features
299299
if (self$param_set$values$recommended) {
300-
score_frame = mlr3misc::invoke(vtreat::get_score_frame, vps = self$state$treatment_plan)
300+
score_frame = invoke(vtreat::get_score_frame, vps = self$state$treatment_plan)
301301
feature_subset = feature_subset[feature_subset %in% score_frame$varName[score_frame$recommended]] # subset to only recommended
302302
}
303303
feature_subset = c(feature_subset, self$param_set$values$cols_to_copy(task)) # respect cols_to_copy

R/TaskRegr_boston_housing.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
#' @name mlr_tasks_boston_housing
55
#' @format [`R6Class`][R6::R6Class] object inheriting from [`TaskRegr`][mlr3::TaskRegr].
66
#'
7-
#' The [`BostonHousing2`][mlbench::BostonHousing2] dataset
7+
#' The [`BostonHousing2`][mlbench::BostonHousing2] dataset
88
#' containing the corrected data from `r format_bib("freeman_1979")`
99
#' as provided by the `mlbench` package. See data description there.
1010
#'
1111
NULL
1212

1313
load_boston_housing = function(id = "boston_housing") {
14-
bh = mlr3misc::load_dataset("BostonHousing2", "mlbench")
14+
bh = load_dataset("BostonHousing2", "mlbench")
1515
bh$medv = NULL
1616
bht = as_task_regr(bh, target = "cmedv", id = id, label = "Boston Housing Prices")
1717
bht$man = "mlr3pipelines::mlr_tasks_boston_housing"

R/mlr_graphs.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#'
4040
#' # all Graphs currently in the dictionary:
4141
#' as.data.table(mlr_graphs)
42-
mlr_graphs = R6Class("DictionaryGraph", inherit = mlr3misc::Dictionary,
42+
mlr_graphs = R6Class("DictionaryGraph", inherit = Dictionary,
4343
cloneable = FALSE,
4444
public = list(
4545
add = function(key, value) {

R/mlr_pipeops.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
#'
6363
#' # all PipeOps currently in the dictionary:
6464
#' as.data.table(mlr_pipeops)[, c("key", "input.num", "output.num", "packages")]
65-
mlr_pipeops = R6Class("DictionaryPipeOp", inherit = mlr3misc::Dictionary,
65+
mlr_pipeops = R6Class("DictionaryPipeOp", inherit = Dictionary,
6666
cloneable = FALSE,
6767
public = list(
6868
metainf = new.env(parent = emptyenv()),

0 commit comments

Comments
 (0)