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
)

Arguments

optimization_result

An OptimizationResult from optimize_panel().

solution_id

Integer specifying which Pareto solution to use. If NULL (default), automatically selects the solution with the best value on the first objective.

features

Character vector of features to use. If provided, overrides the features from solution_id. Must be a subset of the feature pool.

x

Optional training feature matrix. If NULL, uses the stored aggregated training data from the optimization result.

y

Optional training response vector. If NULL, uses the stored response from the optimization result.

cohort

Optional cohort factor. If NULL, uses the stored cohort from the optimization result.

regularized

Logical; if TRUE (default), use regularized regression (elastic net via glmnet). If FALSE, use standard logistic regression.

regularized_alpha

Elastic net mixing parameter when regularized = TRUE. alpha = 1 is lasso, alpha = 0 is ridge. Default is 0.5 (elastic net).

cv

Logical; if TRUE, use cross-validation when fitting the final model (only applies when regularized = FALSE). Default is FALSE.

cv_folds

Number of cross-validation folds when cv = TRUE. Default is 5.

Value

A BiomarkerPanelResult with the fitted model.

Examples

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)
} # }