You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am just gonna leave some code here until I have time to improve and create a PR.
The goal is to reduce the number of unique time points during training in order to make prediction faster.
Would guess this should perhaps live here instead of mlr3pipelines?
PipeOpTimeQuantiles = R6::R6Class("PipeOpTimeQuantiles",
inherit = mlr3pipelines::PipeOpTaskPreproc,
public = list(
#' @description
#' Initialize a Multi-Calibration PipeOp.
#'
#' @param id [`character`] \cr
#' The `PipeOp`'s id. Defaults to "mcboost".
#' @param param_vals [`list`] \cr
#' List of hyperparameters for the `PipeOp`.
initialize = function(id = "timequantiles", param_vals = list()) {
param_set = paradox::ParamSet$new(list(paradox::ParamInt$new("num_uniques", lower = 0L, upper = Inf, default =500L, tags = "train")))
param_set$valus = list("num_uniques" = 500L)
super$initialize(id, param_set = param_set, param_vals = param_vals)
}
),
private = list(
.train_task = function(task) {
times = task$times()
qs = self$param_set$get_values()$num_uniques
if (length(unique(times)) < qs) {
newtimes = times
} else {
qt = round(unique(quantile(unique(times), seq(from = 0, to = 1, length.out = qs), type=2)))
}
# assign closest match
new_target = data.table()
set(new_target, j = task$target_names[[1]], value = qt[apply(abs(outer(qt, times, "-")), 2, which.min)])
task$cbind(new_target)
}
)
)
)
The text was updated successfully, but these errors were encountered:
I am just gonna leave some code here until I have time to improve and create a PR.
The goal is to reduce the number of unique time points during training in order to make prediction faster.
Would guess this should perhaps live here instead of
mlr3pipelines
?The text was updated successfully, but these errors were encountered: