Exhaustive grid search scored by K-fold CV, delegated to
morie_geron_cross_validation_score (hmgrs)
Usage
morie_geron_grid_search(
param_grid,
X,
y,
estimator = NULL,
K = 3,
score = NULL
)
Arguments
- param_grid
Named list of value vectors.
- X, y
Data.
- estimator
function(X_train, y_train, ...) -> predict; default ridge.
- K
Folds.
- score
Optional function(y_true, y_pred) -> score.
Value
List with best_params, best_score, results, n_candidates, n_fits.
Examples
set.seed(3)
X <- matrix(rnorm(60), 30, 2)
y <- 1 + X[, 1] + rnorm(30, 0, 0.2)
r <- morie_geron_grid_search(list(alpha = c(0.1, 1)), X, y, K = 3)
r$best_params
#> $alpha
#> [1] 1
#>