Describe a learner that xplus() uses for both the iterative pseudo-labeling
fits and the final model. Built-in backends are xplus_backend_glmnet(),
xplus_backend_ranger(), xplus_backend_gam(), xplus_backend_xgboost(),
and xplus_backend_lightgbm(); this constructor defines
custom learners with the same contract.
Usage
xplus_backend(
name,
fit,
predict,
importance = NULL,
label = name,
uses_cv = FALSE,
parameters = NULL,
fit_predict = NULL,
supports_fractional = TRUE,
supports_weights = TRUE
)Arguments
- name
Nonempty character scalar identifying the backend.
- fit
Function with signature
fit(x, y, foldid, weights)returning a fitted model object.xis the finite numeric feature matrix,ya numeric target in[0, 1](binary during iterations, possibly fractional in the final fit),foldidthe stratified cross-validation fold assignment, andweightsnonnegative case weights encoding bootstrap multiplicities. To report a cross-validation measure in the iteration history, attachattr(model, "xplus_cv_measure")with"deviance"or"auc"; otherwise"none"is recorded.- predict
Function with signature
predict(model, newx)returning finite probabilities in[0, 1], one per row ofnewx.- importance
Optional function with signature
importance(model)returning a named numeric vector of feature scores, orNULL.- label
Human-readable backend label; defaults to
name.- uses_cv
Logical scalar; whether
fitperforms internal cross-validation whose measure is recorded in the iteration history.- parameters
Optional data frame declaring tunable hyperparameters following the caret
modelInfoconvention (columnsparameter,class, andlabel); informational only, it enables future tuning and AutoML adapters without changing the backend contract.- fit_predict
Optional function with signature
fit_predict(model, x)returning honest probabilities for the rows passed tofit, in the same order — out-of-bag or held-out-fold estimates rather than in-sample memorization.xplus()uses them after the final fit for cutoff calibration and the stored training predictions; non-finite entries fall back topredicton those rows. WhenNULL,predictis reused on training rows, appropriate for learners that do not memorize per-observation targets. Iterative pseudo-label fits always usepredict, which keeps self-training dynamics uniform across backends.- supports_fractional
Logical scalar; whether
fithandles fractional targets in[0, 1](the final pseudo-label fit). WhenFALSE,xplus()fails with a clear error if the final targets are non-binary instead of surfacing an engine-specific error deep in the learner.- supports_weights
Logical scalar; whether
fithonors case weights. WhenFALSE,xplus()warns once thatsampling = "bootstrap"multiplicities will be silently ignored by this learner.
Value
An object of class "xplus_backend" accepted by the backend
argument of xplus().
Details
The contract mirrors the minimal estimator interface shared by
caret modelInfo entries, sklearn fit/predict_proba estimators
(the basis of PU wrappers such as ElkanotoPuClassifier), and mlr3
Learner objects: fit weighted (x, y) data, then predict
probabilities. xplus additionally supplies foldid (stratified CV
folds for backends that use them) and soft fractional targets in the
final fit, which generic frameworks do not provide.