% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/runSA.R
\name{Findbp}
\alias{Findbp}
\title{Search best hyperparameters for SA fitting (lambda and weight decay) by cross-validation}
\usage{
Findbp(
  ocmat,
  enmat = NULL,
  cvmode = c("10fold", "5fold", "loo"),
  nrepeat = 5,
  we = c(0.001),
  maxlrs = c(0.005),
  totalit = 4000,
  lmd = c(5e-04, 0.001, 0.0025, 0.005, 0.0075),
  rep = 8,
  intv = 100,
  threads = 1,
  tol = 0.03,
  runadamW = TRUE,
  sparse = TRUE,
  fastfitting = TRUE,
  reporting = TRUE
)
}
\arguments{
\item{ocmat}{Numeric matrix (0/1). occurrence matrix of the communities.}

\item{enmat}{Optional environmental parameter matrix.}

\item{cvmode}{Cross-validation mode. One of `"10fold"`, `"5fold"`, or `"loo"`.
`"loo"` performs leave-one-out cross-validation. Default is `"10fold"`.}

\item{nrepeat}{Number of repeated cross-validation runs for k-fold CV.
Ignored when `cvmode = "loo"`. Default is `10`.}

\item{we}{Numeric vector. Candidate weight decay values.}

\item{maxlrs}{Numeric vector. Maximum learning rate.}

\item{totalit}{Integer. Total iterations for SA.}

\item{lmd}{Numeric vector. Candidate \code{lambda} values.}

\item{rep}{Integer. Number of replicates for \link{runSA}.}

\item{intv}{Integer. Recording interval.}

\item{threads}{Integer. Number of cores.}

\item{tol}{Numeric. Error tolerance for finding the best hyperparameters (default: 0.03)}

\item{runadamW}{Logical. Use AdamW.}

\item{sparse}{Logical. Use sparsity penalty.}

\item{fastfitting}{Logical. If \code{TRUE}, returns early iterations within the range
specified by the parameter \code{tol} (default: 0.03) of best error.}

\item{reporting}{Logical. Print progress.}
}
\value{
A list with:
\describe{
  \item{best_candidates}{A named list of best hyperparameter settings and scores.}
  \item{allresults}{All validation results for each grid point.}
}
}
\description{
Repeating cross-validation over a grid of hyperparameters for
simulated annealing-based fitting, evaluates prediction/fitting errors on
held-out samples, and returns candidate best parameter/timepoint combinations.
}
