Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
120: Modular emulator interface r=odunbar a=odunbar ## Purpose Reduces the current Emulator interface dependence of Gaussian Processes. Now the GP can be swapped for another statistical emulator. ## In the PR - [x] New general `Emulator` class. This handles all the data manipulation e.g. Normalization, Standardization, Decorrelation - [x] General interface functions for Emulator, `optimize_hyperparameters!`, `predict` - [x] New `MachineLearningTool` type, - [x] Moved the Gaussian Processes into a `GaussianProcess <: MachineLearningTool` class - [x] Example (e.g. `plot_GP`) to demonstrate the new interface - [x] Unit tests - [x] New doc strings. ## Additional change Seems to be ongoing issues with unit testing Julia 1.5.4, so I have updated the Manifest, Docs.yml and Test.yml to Julia 1.6.X ## Changes to user experience: Ingredients: ```julia gppackage = GPJL() pred_type = YType() GPkernel = ... iopairs = PairedDataContainer(x_data,y_data) ``` ### Old interface Set up a `GaussianProcessEmulator` object ```julia gp = GaussianProcess( iopairs, gppackage; GPkernel=GPkernel, obs_noise_cov=nothing, normalized=false, noise_learn=true, truncate_svd=1.0, standardize=false, prediction_type=pred_type, norm_factor=nothing) ``` Then predict with it. ```julia μ, σ² = GaussianProcessEmulator.predict(gp, new_inputs) ``` It is short, but it inherently is stuck to the Gaussian process framework. It also hides e.g. the training away, and we may wish to have this more open. The script below is more general, separating out which parameters are related to data processing and which relate to the specific ML tool. ### New interface Setup a `GaussianProcess<:MachineLearningTool` object ```julia gp = GaussianProcess( gppackage; kernel=GPkernel, noise_learn=true, prediction_type=pred_type) ``` and then create the general emulator type using `gp` ```julia em = Emulator( gp, iopairs, obs_noise_cov=nothing, normalize_inputs=false, standardize_outputs=false, truncate_svd=1.0) ``` Train and predict ```julia Emulators.optimize_hyperparameters!(em) μ, σ² = Emulators.predict(em, new_inputs) ``` ### Adding a new `MachineLearningTool` Include a new file `NewTool.jl` at the top of `Emulator.jl` In this file define: 1. `struct NewTool <: MachineLearningTool` with constructor `NewTool(...)` to hold ML parameters and models 2. `function build_models!(NewTool,iopairs)` to build and store ML models. Called in Emulator constructor 3. `function optimize_hyperparameters!(NewTool)`to train the stored ML models. Called by method of same name in Emulator 4. `function predict(NewTool,new_inputs)` to predict with stored ML models Called by method of same name in Emulator Co-authored-by: odunbar <odunbar@caltech.edu> Co-authored-by: Tom Jackson <tom.jackson314@gmail.com>
- Loading branch information