Version 1.2.0 replaces the graph and preprocessing operators formerly supplied
by mlr3pipelines with internal code. The core runtime retains
mlr3 and mlr3learners for regression interfaces,
mlr3tuning, paradox and bbotk for tuning,
data.table for task backends, and R6 for the internal
learner. No mlr3pipelines installation is required, including for
saved new models.
The six supported learner families still require their statistical backends:
glmnet, ranger, xgboost, rpart,
kknn and e1071 (for svm). Only install
those you request. Reimplementing those modelling algorithms is outside the
scope of the preprocessing replacement. The default algorithm vector requests
all six.
Correlation and variance filtering use internal code. The historical default
information_gain uses optional mlr3filters and
FSelectorRcpp; relief also requires
FSelectorRcpp, carscore requires care,
and cmim requires praznik.
find_correlation uses mlr3filters. Mixed-model
encoding (encodelmer) uses lme4 only when requested.
Missing optional dependencies produce an installation message identifying the
selected feature. knitr builds this vignette and is not needed for
ordinary fitting. Tests use base R without a test framework.
This example uses two inexpensive backends and internal variance filtering.
Install rpart and e1071 if needed. Vignette builds
without these optional packages show the code and skip the model fit.
set.seed(12) training <- data.frame( size = rnorm(60), age = runif(60, 0, 20), group = rep(c("north", "south", "west"), 20), active = rep(c(TRUE, FALSE), 30) ) training$value <- 4 * training$size - training$age / 3 + rnorm(60) training$size[c(3, 10)] <- NA_real_
result <- sense( training, "value", algos = c("rpart", "svm"), selected_filter = "variance", selected_n_feats = 4, missing_fusion = TRUE, ratio = 0.7, budget = 1, n_evals = 1, seed = 42 )
The one-trial budget keeps the example fast; increase it for a substantive
search. Trials are evaluated one at a time. Random search respects both
budget and n_evals; grid search respects
n_evals and resolution. Stagnation and time limits
are checked between trials, so a running fit is not interrupted.
result$test_metrics
#> mse rmse mae mape mdae rae rse rrse #> 99.612872 9.980625 8.042884 8.131120 7.204282 3.184250 13.693000 3.700405 #> smape #> 1.352413
result$selected_n_feats
#> $feats #> [1] "x2_1" "x4_1" "x1_1" "x1_2" #> #> $score #> x1_1 x1_2 x2_1 x3_1 x3_2 x3_3 x4_1 #> 0.25423729 0.25423729 1.00000000 0.22598870 0.22598870 0.22598870 1.00000000 #> missing4 #> 0.03276836
new_data <- training[1:3, setdiff(names(training), "value")] new_data$group[1] <- "unseen-region" result$model_predict(new_data)
#> value #> 1 -5.80 #> 2 -2.48 #> 3 -3.84
result$time_log
#> Time difference of 2.148895 secs
plot(result$plot)

Outer resampling assesses the entire tuning and fitting procedure. Each
inner tuning split trains an independent internal ensemble. Within each
ensemble, three-fold cross-validation produces a prediction for every
training row from base learners that did not train on that row. The meta
learner trains on these predictions; super = "avg" takes their
arithmetic mean. A numerical benchmarking argument selects that
many base algorithms using these out-of-fold scores, respecting whether the
metric is minimized or maximized. Selection is repeated inside each training
split.
Every stacking fold fits its own character-level collapse, imputation
distributions, scaling, factor encodings and feature selection. In particular,
target-based encodings and supervised filters cannot see the held-out outcomes.
For deployment the bases are refitted on their complete training data, and the
prediction function uses the final ensemble trained on all supplied rows.
sampling_rate subsamples base-learner training rows after
preprocessing; validation and prediction rows are not subsampled.
Numeric imputation draws from observed training values (sample)
or their histogram (hist). A completely missing numeric column is
imputed to zero and removed if constant. scale uses the training
mean and standard deviation; range maps the training range to
zero--one; nop leaves numeric values unscaled. Character levels
beyond collapse_char_to are grouped using training frequencies,
with one slot reserved for the collapsed group. Logical columns are
categorical. A separate collision-safe level represents missing values.
Factor encodings include one-hot and treatment, polynomial, sum and Helmert
contrasts; impact encoding uses smoothed differences from the training target
mean. encodelmer fits a random-intercept model using
lme4. New categories receive zero contrasts or zero impact, or the
global mixed-model intercept. Prediction reuses fitted states and column order;
it never refits them. Missing required predictor columns produce an error. A
data set with no nonconstant encoded predictors cannot be fitted.
The public function arguments and nine named result elements are retained.
The plot element is now a lightweight sense_pipeline
object instead of an interactive HTML widget; call plot on it to
draw the architecture. time_log is a difftime in
seconds, replacing a lubridate period. java_mem is accepted for
compatibility but does not change Java options. Internal model layouts have
changed, so code inspecting GraphLearner or PipeOp state must migrate. Old
serialized graph models still need their original dependencies: refit them
with the new version before retiring mlr3pipelines.
benchmark_error now reports final-fit out-of-fold scores rather
than an up-front holdout benchmark. selected_n_feats reports
encoded names and filter scores from the first final base model;
independently fitted bases can select different features after stochastic
imputation. These states are stored with each base model. Changed fold
boundaries and preprocessing mean predictions are not expected to be
numerically identical to version 1.1.0.
The nine test metrics retain their formulas: squared, absolute, percentage,
median and relative errors. They use the rounded testing predictions;
model_error uses mlr3's unrounded predictions. Zero denominators
retain ordinary R semantics (Inf or NaN), including
constant targets for relative errors and zero truth for percentage errors.
Fitting with the same seed is reproducible and restores the caller's random
state. Stochastic imputation during subsequent prediction uses the caller's
random state: call set.seed before predicting if new data contain
missing numbers and identical repeated predictions are required.
saveRDS and readRDS preserve new fitted results,
including their prediction functions.