hyperparameter
MuyGPyS.gp.hyperparameters module reference.
- class MuyGPyS.gp.hyperparameter.scalar.Parameter(val, bounds='fixed')[source]
A MuyGPs kernel or model Hyperparameter. Also called
ScalarParam
.Hyperparameters are defined by a value and optimization bounds. Values must be scalar numeric types, and bounds are either a len == 2 iterable container whose elements are numeric scalars in increasing order, or the string
fixed
. Ifbounds == "fixed"
(the default behavior), the hyperparameter value will remain fixed during optimization.val
must remain within the range of the upper and lower bounds, if notfixed
.- Parameters:
val (
Union
[str
,float
]) – A scalar within the range of the upper and lower bounds (if given). val can also be the strings"sample"
or"log_sample"
, which will result in randomly sampling a value within the range given by the bounds.bounds (
Union
[str
,Tuple
[float
,float
]]) – Iterable container of len 2 containing lower and upper bounds (in that order), or the string"fixed"
.
- Raises:
ValueError – Any
bounds
string other than"fixed"
will produce an error.ValueError – A non-iterable non-string type for
bounds
will produce an error.ValueError – A
bounds
iterable of len other than 2 will produce an error.ValueError – Iterable
bounds
values of non-numeric types will produce an error.ValueError – A lower bound that is not less than an upper bound will produce an error.
ValueError –
val == "sample" or val == "log_sample"
will produce an error ifself._bounds == "fixed"
.ValueError – Any string other than
"sample"
or"log_sample"
will produce an error.ValueError – A
val
outside of the range specified byself._bounds
will produce an error.
- __call__(**kwargs)[source]
Value accessor.
- Return type:
float
- Returns:
The current value of the hyperparameter.
- class MuyGPyS.gp.hyperparameter.tensor.TensorParam(val)[source]
A MuyGPs kernel or model Tensor Hyperparameter.
TensorParam are defined solely by a value, which must be numeric arrays. Currently only used for heteroscedastic noise.
- Parameters:
val (
ndarray
) – A mm.ndarray containing the value of the tensor hyperparameter
- class MuyGPyS.gp.hyperparameter.scale.ScaleFn(val=1.0, **kwargs)[source]
A \(\sigma^2\) covariance scale parameter base functor.
\(\sigma^2\) is a scaling parameter that one multiplies with the found diagonal variances of a
MuyGPyS.gp.muygps.MuyGPS
regression in order to obtain the predicted posterior variance. Trained values assume a number of dimensions equal to the number of response dimensions, and correspond to scalar scaling parameters along the corresponding dimensions.- Parameters:
val (
float
) – A floating point value, if intended to be set manually. Defaults to 1.0.
- __call__()[source]
Value accessor.
- Return type:
ndarray
- Returns:
The current value of the hyperparameter.
- scale_fn(fn)[source]
Modify a function to outer product its output with
scale
.- Parameters:
fn (
Callable
) – A function.- Return type:
Callable
- Returns:
A function that returns the outer product of the output of
fn
- property trained: bool
Report whether the value has been set.
- Returns:
True
if trained,False
otherwise.
- class MuyGPyS.gp.hyperparameter.scale.FixedScale(val=1.0, **kwargs)[source]
A \(\sigma^2\) covariance scale parameter.
A
Scale
parameter with a null optimization method. This parameter is therefore insensitive to optimization.- Parameters:
response_count – The integer number of response dimensions.
- class MuyGPyS.gp.hyperparameter.scale.AnalyticScale(iteration_count=1, _backend_fn=<function _analytic_scale_optim>, **kwargs)[source]
An optimizable \(\sigma^2\) covariance scale parameter.
Identical to
FixedScale
, save that itsget_opt_fn
method performs an analytic optimization.- Parameters:
response_count – The integer number of response dimensions.
iteration_count (
int
) – The number of iterations to run during optimization.
- get_opt_fn(muygps)[source]
Get a function to optimize the value of the \(\sigma^2\) scale parameter for each response dimension.
We approximate a scalar \(\sigma^2\) by way of averaging over the analytic solution from each local kernel. Given observations \(X\) with responses \(Y\), noise model \(\varepsilon\), and kernel function \(Kin_\theta(\cdot, \cdot)\), computes:
\[\sigma^2 = \frac{1}{bk} * \sum_{i \in B} Y(X_{N_i})^T \left ( Kin_\theta(X_{N_i}, X_{N_i}) + \varepsilon_{N_i} \right )^{-1} Y(X_{N_i}).\]Here \(N_i\) is the set of nearest neighbor indices of the \(i`th batch element, :math:`k\) is the number of nearest neighbors and \(b = |B|\) is the number of batch elements considered.
- Parameters:
muygps – The model to used to create and perturb the kernel.
- Return type:
Callable
- Returns:
A function with signature
(Kin, nn_targets, *args, **kwargs) -> mm.ndarray
that perturbs the(batch_count, nn_count, nn_count)
tensorKin
withmuygps
’s noise model before solving it against the(batch_count, nn_count, response_count)
tensornn_targets
.