Takes an OptimizationResult from optimize_panel() and fits a model on
a selected Pareto solution. Returns a BiomarkerPanelResult with the
fitted model ready for evaluation.
fit_panel(
optimization_result,
solution_id = NULL,
features = NULL,
x = NULL,
y = NULL,
cohort = NULL,
regularized = TRUE,
regularized_alpha = 0.5,
cv = FALSE,
cv_folds = 5L
)An OptimizationResult from optimize_panel().
Integer specifying which Pareto solution to use. If
NULL (default), automatically selects the solution with the best
value on the first objective.
Character vector of features to use. If provided, overrides
the features from solution_id. Must be a subset of the feature pool.
Optional training feature matrix. If NULL, uses the stored
aggregated training data from the optimization result.
Optional training response vector. If NULL, uses the stored
response from the optimization result.
Optional cohort factor. If NULL, uses the stored cohort
from the optimization result.
Logical; if TRUE (default), use regularized regression
(elastic net via glmnet). If FALSE, use standard logistic regression.
Elastic net mixing parameter when regularized = TRUE.
alpha = 1 is lasso, alpha = 0 is ridge. Default is 0.5 (elastic net).
Logical; if TRUE, use cross-validation when fitting the final
model (only applies when regularized = FALSE). Default is FALSE.
Number of cross-validation folds when cv = TRUE.
Default is 5.
A BiomarkerPanelResult with the fitted model.
if (FALSE) { # \dontrun{
# Run optimization
opt <- optimize_panel(x, y, objectives = define_objectives())
# Inspect solutions
summarize_solutions(opt)
# Fit model on best solution (auto-selected)
panel <- fit_panel(opt)
# Or specify a particular solution
panel <- fit_panel(opt, solution_id = 3)
# Evaluate on held-out data
evaluate_panel(panel, x_test, y_test)
} # }