data(mtcars)
grid.search(
formula = mpg ~ .,
data = mtcars,
K = 5L, # Use 5-fold CV
max.lambda = 100, # Search values between 0 and 100
precision = 0.01, # Increment in steps of 0.01
verbose = FALSE, # Disable progress bar
)
# \donttest{
set.seed(1L)
n <- 50002L
DF <- data.frame(
x1 = rnorm(n),
x2 = runif(n),
x3 = rlogis(n),
x4 = rnorm(n),
x5 = rcauchy(n),
x6 = rexp(n)
)
DF <- transform(
DF,
y = 3.1 * x1 + 1.8 * x2 + 0.9 * x3 + 1.2 * x4 + x5 + 0.6 * x6 + rnorm(n, sd = 10)
)
grid.search(
formula = y ~ .,
data = DF,
K = 10L, # Use 10-fold CV
max.lambda = 100, # Search values between 0 and 100
precision = 1, # Increment in steps of 1
n.threads = 10L # Use 10 threads
)
grid.search(
formula = y ~ .,
data = DF,
K = n, generalized = TRUE, # Use generalized CV
max.lambda = 10000, # Search values between 0 and 10000
precision = 10, # Increment in steps of 10
)
# }
Run the code above in your browser using DataLab