Creates a trans_models_t table for storing transition model metadata and serialized model objects. This function creates an empty table with proper structure for storing fitted models via the mlr3 interface.
Usage
as_trans_models_t(x)
fit_partial_models(
self,
learner,
measures,
sample_frac = 0.7,
seed = NULL,
cluster = NULL
)
fit_full_models(
self,
learner = NULL,
select_score = NULL,
select_maximize = TRUE,
cluster = NULL
)
# S3 method for class 'trans_models_t'
print(x, ...)
get_crossval_plots(self, id_run = NULL, id_trans = NULL)Arguments
- x
A list or data.frame coercible to a data.table
- self
evoland_db instance
- learner
An mlr3
LearnerorAutoTunerobject for direct-learner mode that supports twoclass classification. Itspredict_typeis coerced to"prob"if not already set. Must beNULLwhenselect_scoreis provided.- measures
Either a character vector of mlr3 measure IDs (e.g.
c("classif.auc", "classif.acc")) or a list of instantiated mlr3Measureobjects (e.g.list(mlr3::msr("classif.auc"))). Character IDs are converted viamlr3::msrs()internally. Results are written tocrossval_score.- sample_frac
Numeric between 0 and 1 indicating the fraction of data to use for training the partial models. The rest is used for testing and calculating goodness-of-fit metrics. Default is 0.7 (70% training, 30% testing).
- seed
Optional integer seed for reproducible subsampling.
- cluster
An optional cluster object created by
parallel::makeCluster()ormirai::make_cluster().- select_score
Character string; mlr3 measure ID (e.g.
"classif.auc") used to rank partial models in score-select mode. Must beNULLwhenlearneris provided.- select_maximize
Logical; if
TRUE(default) the model with the highestselect_scoreis selected; ifFALSE, the lowest. Only used in score-select mode.- ...
ignored
- id_run
Optional integer; filter by run ID.
- id_trans
Optional integer; filter by transition ID.
Value
A data.table of class "trans_models_t" with columns:
id_run: Foreign key to runs_tid_trans: Foreign key to trans_meta_tlearner_id: mlr3 twoclass LearnerClassif key, e.g."classif.ranger"learner_params: MAP of atomic scalar learner hyperparameters for querying; complete hyperparameters are captured bylearner_speclearner_spec: BLOB of serialized untrained mlr3Learner; for AutoTuners, this is the optimal inner learner after tuningcrossval_score: MAP of cross-validation performance scores (fromprediction$score(measures))crossval_predictions: BLOB of serialized mlr3PredictionClassifon the held-out test splitlearner_full: BLOB of serialized trained mlr3Learnerfitted on the full dataset, used for extrapolation
Methods (by generic)
print(trans_models_t): Print a trans_models_t object as yaml-style list; additional arguments silently ignored
Functions
fit_partial_models(): Fit partial (cross-validation) models for each viable transition; returns a trans_models_t object with one row per viable transition, containing the learner identity, serialized spec, cross-validation scores (crossval_score), and serialized held-out predictions (crossval_predictions).fit_full_models(): Fit full models (trained on the complete dataset) for each viable transition and return a trans_models_t object withlearner_fullpopulated. Two mutually exclusive modes are supported:Direct-learner mode (
learnerprovided,select_scoreomitted): a fresh clone oflearneris trained on the full data for each transition.crossval_scoreandcrossval_predictionswill beNULLin the result. Does not require a prior call tofit_partial_models().Score-select mode (
select_scoreprovided,learneromitted): selects the best partial model per transition byselect_score, reconstructs its learner fromlearner_spec, and retrains on the full data. Requiresfit_partial_models()to have been run first.
get_crossval_plots(): Deserialize cross-validation predictions and return plots viamlr3viz::autoplot(). Requires themlr3vizpackage.