Findbp: Search best hyperparameters for SA fitting (lambda and weight...

View source: R/runSA.R

FindbpR Documentation

Search best hyperparameters for SA fitting (lambda and weight decay) by cross-validation

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.

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

ocmat

Numeric matrix (0/1). occurrence matrix of the communities.

enmat

Optional environmental parameter matrix.

cvmode

Cross-validation mode. One of '"10fold"', '"5fold"', or '"loo"'. '"loo"' performs leave-one-out cross-validation. Default is '"10fold"'.

nrepeat

Number of repeated cross-validation runs for k-fold CV. Ignored when 'cvmode = "loo"'. Default is '10'.

we

Numeric vector. Candidate weight decay values.

maxlrs

Numeric vector. Maximum learning rate.

totalit

Integer. Total iterations for SA.

lmd

Numeric vector. Candidate lambda values.

rep

Integer. Number of replicates for runSA.

intv

Integer. Recording interval.

threads

Integer. Number of cores.

tol

Numeric. Error tolerance for finding the best hyperparameters (default: 0.03)

runadamW

Logical. Use AdamW.

sparse

Logical. Use sparsity penalty.

fastfitting

Logical. If TRUE, returns early iterations within the range specified by the parameter tol (default: 0.03) of best error.

reporting

Logical. Print progress.

Value

A list with:

best_candidates

A named list of best hyperparameter settings and scores.

allresults

All validation results for each grid point.


ELAplus documentation built on May 28, 2026, 5:09 p.m.