LLNL / MuyGPyS

A fast, pure python implementation of the MuyGPs Gaussian process realization and training algorithm.
Other
23 stars 11 forks source link

Refactor `__init__` methods throughout #116

Closed bwpriest closed 1 year ago

bwpriest commented 1 year ago

Right now we are initializing lower level classes (KernelFns and Hyperparameters) inside of MuyGPS. However, I believe that we want to modify this so that the user creates the lower lever classes directly, and passes them to MuyGPS. This will serve to both make the API more readable and make the code internals more maintainable.

The proposed change would move the current creation logic from

k_kwargs = {
    "kern": "matern",
    "metric": "l2",
    "eps": {"val": 1e-5},
    "nu": {"val": "log_sample", "bounds": (0.1, 5.0)},
    "length_scale": {"val": 1.0},
}
muygps = MuyGPS(**k_kwargs)

to something like

muygps = MuyGPS(
    Matern(
        disortion=Isotropic("l2"), 
        nu=Hyperparameter("log_sample", (0.1, 5.0))
        length_scale=Hyperparameter(1.0),
    ),
    eps=HomoscedasticNoise(1e-5),
    sigma_sq=SigmaSq(1.0),
)
bwpriest commented 1 year ago

Another advantage this provides is that model choices are explicit. Instead of depending implicitly upon conventions (e.g. eps type determined by the shape of the passed value), the user explicitly declares the model choices at intialization time.

alecmdunton commented 1 year ago

This will be a lot cleaner

bwpriest commented 1 year ago

Addressed with PR #118