Skip to contents

Exact Gaussian process regression with a constant mean, a scaled kernel, and a Gaussian likelihood. The hyperparameters are fitted by maximizing the exact marginal log likelihood with the Adam optimizer. Uses reticulate to interface with the gpytorch Python package.

The features and the target are standardized to zero mean and unit variance before the model is fitted, and the predictions are transformed back to the original scale. The standard error is the posterior standard deviation of the latent function, i.e. it does not include the observation noise.

Custom mlr3 parameters

gpytorch has no ready-made training function, so all parameters are defined by this learner.

  • kernel is the base kernel that is wrapped in a ScaleKernel. "rbf" is the RBFKernel, and "matern_0.5", "matern_1.5", and "matern_2.5" are the MaternKernel with the respective smoothness parameter nu.

  • lr is the learning rate of the Adam optimizer.

  • n_iter is the number of optimizer steps.

  • device is the torch device on which the model is fitted and predictions are computed. "auto" selects "cuda" if available and "cpu" otherwise.

Installation

This learner relies on reticulate to handle Python dependencies. It is not necessary to install any Python package manually in advance or specify a Python environment via reticulate::use_python(), reticulate::use_virtualenv(), reticulate::use_condaenv(), or reticulate::use_miniconda(). By calling $train() or $predict(), the required Python packages (gpytorch and torch) will be installed automatically, if not already. Reticulate will then configure and initialize an ephemeral environment satisfying those requirements, unless an existing environment (e.g., "r-reticulate") in reticulate's Order of Discovery contains all the necessary packages.

You may also manually install gpytorch into a Python environment and specify the environment via reticulate::use_*() before calling $train() or $predict(), for example:

reticulate::virtualenv_create("gpytorch", packages = c("torch", "gpytorch"))
reticulate::use_virtualenv("gpytorch", required = TRUE)

Saving a Learner

In order to save a LearnerRegrGPyTorch for later usage, it is necessary to call the $marshal() method on the Learner before writing it to disk, as the object will otherwise not be saved correctly. After loading a marshaled LearnerRegrGPyTorch into R again, you then need to call $unmarshal() to transform it into a useable state.

Dictionary

This Learner can be instantiated via lrn():

lrn("regr.gpytorch")

Meta Information

  • Task type: “regr”

  • Predict Types: “response”, “se”

  • Feature Types: “integer”, “numeric”

  • Required Packages: mlr3, mlr3extralearners, reticulate

Parameters

IdTypeDefaultLevelsRange
kernelcharacterrbfrbf, matern_0.5, matern_1.5, matern_2.5-
lrnumeric0.1\([0, \infty)\)
n_iterinteger50\([1, \infty)\)
devicecharacterautoauto, cpu, cuda-

References

Gardner, R J, Pleiss, Geoff, Weinberger, Q K, Bindel, David, Wilson, Gordon A (2018). “GPyTorch: Blackbox Matrix-Matrix Gaussian Process Inference with GPU Acceleration.” In Advances in Neural Information Processing Systems, volume 31.

See also

Author

KhalifaSeck

Super classes

mlr3::Learner -> mlr3::LearnerRegr -> LearnerRegrGPyTorch

Active bindings

marshaled

(logical(1))
Whether the learner has been marshaled.

Methods

Inherited methods


LearnerRegrGPyTorch$new()

Creates a new instance of this R6 class.

Usage


LearnerRegrGPyTorch$marshal()

Marshal the learner's model.

Usage

LearnerRegrGPyTorch$marshal(...)

Arguments

...

(any)
Additional arguments passed to mlr3::marshal_model().


LearnerRegrGPyTorch$unmarshal()

Unmarshal the learner's model.

Usage

LearnerRegrGPyTorch$unmarshal(...)

Arguments

...

(any)
Additional arguments passed to mlr3::unmarshal_model().


LearnerRegrGPyTorch$clone()

The objects of this class are cloneable with this method.

Usage

LearnerRegrGPyTorch$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.