% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tuning.R
\name{tl_tune_grid}
\alias{tl_tune_grid}
\title{Tune hyperparameters for a model using grid search}
\usage{
tl_tune_grid(
  data,
  formula,
  method,
  param_grid,
  folds = 5,
  metric = NULL,
  maximize = NULL,
  verbose = TRUE,
  ...
)
}
\arguments{
\item{data}{A data frame containing the training data}

\item{formula}{A formula specifying the model}

\item{method}{The modeling method to tune}

\item{param_grid}{A named list of parameter values
to tune}

\item{folds}{Number of cross-validation folds}

\item{metric}{Metric to optimize}

\item{maximize}{Logical; whether to maximize (TRUE)
or minimize (FALSE) the metric}

\item{verbose}{Logical; whether to print progress}

\item{...}{Additional arguments passed to tl_model}
}
\value{
A tidylearn model object fitted with the best hyperparameters.
Tuning results are stored as an attribute \code{"tuning_results"},
a list containing \code{param_grid}, \code{results} (data frame of
all evaluated combinations), \code{best_params}, \code{best_metric},
\code{metric}, and \code{maximize}.
}
\description{
Tune hyperparameters for a model using grid search
}
\examples{
\donttest{
model <- tl_tune_grid(iris, Species ~ ., method = "tree",
  param_grid = list(cp = c(0.01, 0.1), minsplit = c(10, 20)),
  folds = 2, verbose = FALSE)
}
}
