R6_hype: Hyperparameter optimization

R6_hypeR Documentation

Hyperparameter optimization

Description

Hyperparameter optimization

Hyperparameter optimization

Public fields

X

Data frame of inputs that have been evaluated or will be evaluated next.

Z

Output at X

runtime

The time it took to evaluate each row of X

parnames

Names of the parameters

parlowerraw

Lower bounds for each parameter on raw scale

parupperraw

Upper bounds for each parameter on raw scale

parlowertrans

Lower bounds for each parameter on transformed scale

paruppertrans

Upper bounds for each parameter on transformed scale

parlist

List of all parameters

modlist

A list with details about the model. The user shouldn't ever edit this directly.

ffexp

An ffexp R6 object used to run the experiment and store the results.

eval_func

The function we evaluate.

extract_output_func

A function that takes in the output from 'eval_func' and returns the value we are trying to minimize.

par_all_cts

Are all the parameters continuous?

verbose

How much should be printed? 0 is none, 1 is standard, 2 is more, 5+ is a lot

Active bindings

mod

Gaussian process model used to predict what the output will be.

Methods

Public methods


Method new()

Create hype R6 object.

Usage
R6_hype$new(
  eval_func,
  ...,
  X0 = NULL,
  Z0 = NULL,
  n_lhs,
  extract_output_func,
  verbose = 1,
  model = "GauPro",
  covtype = "matern5_2",
  nugget.estim = TRUE
)
Arguments
eval_func

The function used to evaluate new points.

...

Hyperparameters to optimize over.

X0

Data frame of initial points to run, or points already evaluated. If already evaluated, give in outputs in "Z0"

Z0

Evaluated outputs at "X0".

n_lhs

The number that should initially be run using a maximin Latin hypercube.

extract_output_func

A function that takes in the output from 'eval_func' and returns the value we are trying to minimize.

verbose

How much should be printed? 0 is none, 1 is standard, 2 is more, 5+ is a lot

model

What package to fit the Gaussian process model with. Either "GauPro" or "DiceKriging"/"DK".

covtype

Covariance/correlation/kernel function for the GP model.

nugget.estim

Should the nugget be estimated when fitting the GP model?


Method add_data()

Add data to the experiment results.

Usage
R6_hype$add_data(X, Z)
Arguments
X

Data frame with names matching the input parameters

Z

Output at rows of X matching the experiment output.


Method add_X()

Add new inputs to run. This allows the user to specify what they want run next.

Usage
R6_hype$add_X(X)
Arguments
X

Data frame with names matching the input parameters.


Method add_LHS()

Add new input points using a maximin Latin hypercube. Latin hypercubes are usually more spacing than randomly picking points.

Usage
R6_hype$add_LHS(n, just_return_df = FALSE)
Arguments
n

Number of points to add.

just_return_df

Instead of adding to experiment, should it just return the new set of values?


Method convert_trans_to_raw()

Convert parameters from transformed scale to raw scale.

Usage
R6_hype$convert_trans_to_raw(Xtrans)
Arguments
Xtrans

Parameters on the transformed scale


Method convert_raw_to_trans()

Convert parameters from raw scale to transformed scale.

Usage
R6_hype$convert_raw_to_trans(Xraw)
Arguments
Xraw

Parameters on the raw scale


Method change_par_bounds()

Change lower/upper bounds of a parameter

Usage
R6_hype$change_par_bounds(parname, lower, upper)
Arguments
parname

Name of the parameter

lower

New lower bound. Leave empty if not changing.

upper

New upper bound. Leave empty if not changing.


Method add_EI()

Add new inputs to run using the expected information criteria

Usage
R6_hype$add_EI(
  n,
  covtype = NULL,
  nugget.estim = NULL,
  model = NULL,
  eps,
  just_return = FALSE,
  calculate_at
)
Arguments
n

Number of points to add.

covtype

Covariance function to use for the Gaussian process model.

nugget.estim

Should a nugget be estimated?

model

Which package should be used to fit the model and calculate the EI? Use "DK" for DiceKriging or "GauPro" for GauPro.

eps

Exploration parameter. The minimum amount of improvement you care about.

just_return

Just return the EI info, don't actually add the points to the design.

calculate_at

Calculate the EI at a specific point.


Method fit_mod()

Fit model to the data collected so far

Usage
R6_hype$fit_mod(covtype = NULL, nugget.estim = NULL, model = NULL)
Arguments
covtype

Covariance function to use for the Gaussian process model.

nugget.estim

Should a nugget be estimated?

model

Which package should be used to fit the model and calculate the EI? Use "DK" for DiceKriging or "GauPro" for GauPro.


Method run_all()

Run all unevaluated input points.

Usage
R6_hype$run_all(...)
Arguments
...

Passed into ‘ffexp$run_all'. Can set ’parallel=TRUE' to evaluate multiple points simultaneously as long as all needed variables have been passed to 'varlist'


Method run_EI_for_time()

Add points using the expected information criteria, evaluate them, and repeat until a specified amount of time has passed.

Usage
R6_hype$run_EI_for_time(
  sec,
  batch_size,
  covtype = "matern5_2",
  nugget.estim = TRUE,
  verbose = 0,
  model = "GauPro",
  eps = 0,
  ...
)
Arguments
sec

Number of seconds to run for. It will go over this time limit, finish the current iteration, then stop.

batch_size

Number of points to run at once.

covtype

Covariance function to use for the Gaussian process model.

nugget.estim

Should a nugget be estimated?

verbose

Verbose parameter to pass to ffexp$

model

Which package should be used to fit the model and calculate the EI? Use "DK" for DiceKriging or "GauPro" for GauPro.

eps

Exploration parameter. The minimum amount of improvement you care about.

...

Passed into 'ffexp$run_all'.


Method plot()

Make a plot to summarize the experiment.

Usage
R6_hype$plot()

Method pairs()

Plot pairs of inputs and output

Usage
R6_hype$pairs()

Method plotorder()

Plot the output of the points evaluated in order.

Usage
R6_hype$plotorder()

Method plotX()

Plot the output as a function of each input.

Usage
R6_hype$plotX(
  addlines = TRUE,
  addEIlines = TRUE,
  covtype = NULL,
  nugget.estim = NULL,
  model = NULL
)
Arguments
addlines

Should prediction mean and 95% interval be plotted?

addEIlines

Should expected improvement lines be plotted?

covtype

Covariance function to use for the Gaussian process model.

nugget.estim

Should a nugget be estimated?

model

Which package should be used to fit the model and calculate the EI? Use "DK" for DiceKriging or "GauPro" for GauPro.


Method plotXorder()

Plot each input in the order they were chosen. Colored by quality.

Usage
R6_hype$plotXorder()

Method plotinteractions()

Plot the 2D plots from inputs to the output. All other variables are held at their values for the best input.

Usage
R6_hype$plotinteractions(covtype = "matern5_2", nugget.estim = TRUE)
Arguments
covtype

Covariance function to use for the Gaussian process model.

nugget.estim

Should a nugget be estimated?


Method print()

Print details of the object.

Usage
R6_hype$print(...)
Arguments
...

not used


Method best_params()

Returns the best parameters evaluated so far.

Usage
R6_hype$best_params()

Method update_mod_userspeclist()

Updates the specifications for the GP model.

Usage
R6_hype$update_mod_userspeclist(
  model = NULL,
  covtype = NULL,
  nugget.estim = NULL
)
Arguments
model

What package to fit the Gaussian process model with. Either "GauPro" or "DiceKriging"/"DK".

covtype

Covariance/correlation/kernel function for the GP model.

nugget.estim

Should the nugget be estimated when fitting the GP model?


Method clone()

The objects of this class are cloneable with this method.

Usage
R6_hype$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


# Have df output, but only use one value from it
h1 <- hype(
  eval_func = function(a, b) {data.frame(c=a^2+b^2, d=1:2)},
  extract_output_func = function(odf) {odf$c[1]},
  a = par_unif('a', -1, 2),
  b = par_unif('b', -10, 10),
  n_lhs = 10
)
h1$run_all()
h1$add_EI(n = 1)
h1$run_all()
#system.time(h1$run_EI_for_time(sec=3, batch_size = 1))
#system.time(h1$run_EI_for_time(sec=3, batch_size = 3))
h1$plotorder()
h1$plotX()

comparer documentation built on March 7, 2023, 7:49 p.m.