% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bandwidth_grid.R
\name{score_bandwidth_candidate}
\alias{score_bandwidth_candidate}
\title{Score a single bandwidth candidate}
\usage{
score_bandwidth_candidate(context, bandwidth, scorer)
}
\arguments{
\item{context}{A `gwpr_context` list.}

\item{bandwidth}{Numeric scalar; the candidate bandwidth to evaluate.}

\item{scorer}{A function with signature `scorer(context, bandwidth)`
returning a named list with at minimum:
\describe{
  \item{`score`}{Numeric scalar.  The criterion value (lower is better).}
  \item{`criterion`}{Character scalar.  Name of the criterion.}
  \item{`n_local_models`}{Integer.  Number of local models attempted.}
  \item{`n_failed_local_models`}{Integer.  Number of local models that
    failed.}
  \item{`metrics`}{Named list of aggregate metrics (e.g. R2, MSE, etc.).}
}}
}
\value{
A named list describing the candidate result:
\describe{
  \item{`bandwidth`}{The evaluated bandwidth.}
  \item{`score`}{Numeric criterion score, or `NA_real_` on failure.}
  \item{`criterion`}{Name of the scoring criterion.}
  \item{`status`}{`"ok"` or `"failed"`.}
  \item{`error_message`}{`NA_character_` or error text.}
  \item{`warning_message`}{`NA_character_` or warning text.}
  \item{`elapsed_time`}{Elapsed wall-clock time in seconds.}
  \item{`n_local_models`}{Number of local models attempted.}
  \item{`n_failed_local_models`}{Number of local models that failed.}
  \item{`r2`, `mse`, `rmse`, `mae`}{Linear metrics, or `NA_real_`.}
  \item{`log_loss`, `accuracy`, `precision`, `recall`, `f1_score`}{Logistic
    metrics, or `NA_real_`.}
}
}
\description{
Calls the `scorer` function for a given bandwidth and records the result
together with timing information, model counts, and metric values.
}
\keyword{internal}
