deformation
MuyGPyS.gp.deformation module reference.
- class MuyGPyS.gp.deformation.Isotropy(metric, length_scale)[source]
An isotropic deformation model.
Isotropy defines a scaled elementwise distance function \(d_ell(\cdot, \cdot)\), and is paramterized by a scalar \(\ell>0\) length scale hyperparameter.
\[d_\ell(\mathbf{x}, \mathbf{y}) = \sum_{i=0}^d \frac{d(\mathbf{x}_i, \mathbf{y}_i)}{\ell}\]- Parameters:
- __call__(dists, length_scale=None, **kwargs)[source]
Apply isotropic deformation to an elementwise difference tensor.
This function is not intended to be invoked directly by a user. It is instead functionally incorporated into some
MuyGPyS.gp.kernels.KernelFnin its constructor.- Parameters:
dists (
ndarray) – A tensor of distances between sets of observables.length_scale (
Union[float,ndarray,None]) – A floating point length scale.
- Return type:
ndarray- Returns:
A scaled distance tensor of the same shape as \(dists\).
- crosswise_tensor(data, nn_data, data_indices, nn_indices, **kwargs)[source]
Compute a crosswise distance tensor between data and their nearest neighbors.
Takes full datasets of records of interest
dataand neighbor candidatesnn_dataand produces a scalar distance between each element ofdataindicated bydata_indicesand each of the nearest neighbors innn_dataas indicated by the corresponding rows ofnn_indices.dataandnn_datacan refer to the same dataset.- Parameters:
data (
ndarray) – The data matrix of shape(data_count, feature_count)containing batch elements.nn_data (
ndarray) – The data matrix of shape(candidate_count, feature_count)containing the universe of candidate neighbors for the batch elements. Might be the same asdata.indices – An integral vector of shape
(batch_count,)containing the indices of the batch.nn_indices (
ndarray) – An integral matrix of shape (batch_count, nn_count) listing the nearest neighbor indices for the batch of data points.
- Return type:
ndarray- Returns:
A tensor of shape
(batch_count, nn_count)whose second dimension indicates distance vectors between each batch element and its nearest neighbors.
- pairwise_tensor(data, nn_indices, **kwargs)[source]
Compute a pairwise distance tensor among sets of nearest neighbors.
Takes a full dataset of records of interest
dataand produces the pairwise distances between the elements indicated by each row ofnn_indices.- Parameters:
data (
ndarray) – The data matrix of shape(batch_count, feature_count)containing batch elements.nn_indices (
ndarray) – An integral matrix of shape (batch_count, nn_count) listing the nearest neighbor indices for the batch of data points.
- Return type:
ndarray- Returns:
A tensor of shape
(batch_count, nn_count, nn_count)containing the(nn_count, nn_count)-shaped pairwise nearest neighbor distance tensors corresponding to each of the batch elements.
- class MuyGPyS.gp.deformation.Anisotropy(metric, length_scale)[source]
An anisotropic deformation model.
Anisotropy parameterizes a scaled elementwise distance function \(d_\ell(\cdot, \cdot)\), and is paramterized by a vector-valued \(\mathbf{\ell}>0\) length scale hyperparameter.
\[d_\ell(\mathbf{x}, \mathbf{y}) = \sum_{i=0}^d \frac{d(\mathbf{x}_i, \mathbf{y}_i)}{\ell_i}\]- Parameters:
metric (
MetricFn) – A MetricFn object defining the behavior of the feature metric space.length_scales – Keyword arguments
length_scale#, mapping to scalar hyperparameters.
- __call__(dists, **length_scales)[source]
Apply anisotropic deformation to an elementwise difference tensor.
This function is not intended to be invoked directly by a user. It is instead functionally incorporated into some
MuyGPyS.gp.kernels.KernelFnin its constructor.- Parameters:
dists (
ndarray) – A difference tensor of shape(..., feature_count)listing feature-wise differences among a set of observables.batch_features – A
(batch_count, feature_count)matrix of features to be used with a hierarchical hyperparameter.Noneotherwise.length_scale – A floating point length scale, or a vector of
(knot_count,)knot length scales.
- Return type:
ndarray- Returns:
A scaled distance tensor of the same shape as \(dists\) less the final dimension.
- crosswise_tensor(data, nn_data, data_indices, nn_indices, **kwargs)[source]
Compute a crosswise difference tensor between data and their nearest neighbors.
Takes full datasets of records of interest
dataand neighbor candidatesnn_dataand produces a difference vector between each element ofdataindicated bydata_indicesand each of the nearest neighbors innn_dataas indicated by the corresponding rows ofnn_indices.dataandnn_datacan refer to the same dataset.- Parameters:
data (
ndarray) – The data matrix of shape(data_count, feature_count)containing batch elements.nn_data (
ndarray) – The data matrix of shape(candidate_count, feature_count)containing the universe of candidate neighbors for the batch elements. Might be the same asdata.indices – An integral vector of shape
(batch_count,)containing the indices of the batch.nn_indices (
ndarray) – An integral matrix of shape (batch_count, nn_count) listing the nearest neighbor indices for the batch of data points.
- Return type:
ndarray- Returns:
A tensor of shape
(batch_count, nn_count, feature_count)whose last two dimensions indicate difference vectors between the feature dimensions of each batch element and those of its nearest neighbors.
- pairwise_tensor(data, nn_indices, **kwargs)[source]
Compute a pairwise difference tensor among sets of nearest neighbors.
Takes a full dataset of records of interest
dataand produces the pairwise differences for each feature dimension between the elements indicated by each row ofnn_indices.- Parameters:
data (
ndarray) – The data matrix of shape(batch_count, feature_count)containing batch elements.nn_indices (
ndarray) – An integral matrix of shape (batch_count, nn_count) listing the nearest neighbor indices for the batch of data points.
- Return type:
ndarray- Returns:
A tensor of shape
(batch_count, nn_count, nn_count, feature_count)containing the(nn_count, nn_count, feature_count)-shaped pairwise nearest neighbor difference tensors corresponding to each of the batch elements.