Skip to contents

Returns the N parameter sets which resulted in the maximum scores from FUN.

Usage

getBestPars(optObj, N = 1)

Arguments

optObj

An object of class bayesOpt

N

The number of parameter sets to return

Value

A list containing the FUN inputs which resulted in the highest returned Score. If N > 1, a data.table is returned. Each row is a result from FUN, with results ordered by descending Score.

Examples

scoringFunction <- function(x) {
  a <- exp(-(2-x)^2)*1.5
  b <- exp(-(4-x)^2)*2
  c <- exp(-(6-x)^2)*1
  return(list(Score = a+b+c))
}

bounds <- list(x = c(0,8))

Results <- bayesOpt(
    FUN = scoringFunction
  , bounds = bounds
  , initPoints = 3
  , iters.n = 2
  , gsPoints = 10
)
#> Ran initial scoring function 3 times in 1 thread: 0.673999999999999 seconds.
#> Starting Epoch 1
#>   1) Fitting Gaussian Process...
#>   2) Ran local optimum search: 0.0549999999999997 seconds.
#>   3) Ran `FUN()` 1 time in 1 thread: 0.234999999999999 seconds.
#> Starting Epoch 2
#>   1) Fitting Gaussian Process...
#>   2) Ran local optimum search: 0.0760000000000005 seconds.
#>   3) Ran `FUN()` 1 time in 1 thread: 0.262999999999998 seconds.
print(getBestPars(Results))
#> $x
#> [1] 2.376256
#>