Skip to content

Commit

Permalink
Merge pull request #244 from alan-turing-institute/simplify
Browse files Browse the repository at this point in the history
Simplify
  • Loading branch information
mastoffel authored Sep 18, 2024
2 parents 70cc05c + 714d657 commit 84211df
Show file tree
Hide file tree
Showing 22 changed files with 580 additions and 1,039 deletions.
2 changes: 1 addition & 1 deletion autoemulate/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def setup(
param_search : bool
Whether to perform hyperparameter search over predifined parameter grids.
param_search_type : str
Type of hyperparameter search to perform. Can be "grid", "random", or "bayes".
Type of hyperparameter search to perform. Currently only "random".
param_search_iters : int
Number of parameter settings that are sampled. Only used if
param_search=True and param_search_type="random".
Expand Down
19 changes: 7 additions & 12 deletions autoemulate/emulators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from .conditional_neural_process import ConditionalNeuralProcess
from .gaussian_process import GaussianProcess
from .gaussian_process_mogp import GaussianProcessMOGP
from .gaussian_process_sklearn import GaussianProcessSklearn
from .gaussian_process_torch import GaussianProcessTorch
from .gradient_boosting import GradientBoosting
from .light_gbm import LightGBM
from .neural_net_sk import NeuralNetSk
from .neural_net_torch import NeuralNetTorch
from .polynomials import SecondOrderPolynomial
from .radial_basis_functions import RadialBasisFunctions
from .random_forest import RandomForest
Expand All @@ -16,16 +15,12 @@
RadialBasisFunctions().model_name: RadialBasisFunctions(),
RandomForest().model_name: RandomForest(),
GradientBoosting().model_name: GradientBoosting(),
GaussianProcess().model_name: GaussianProcess(),
SupportVectorMachines().model_name: SupportVectorMachines(),
LightGBM().model_name: LightGBM(),
NeuralNetTorch(module="MultiLayerPerceptron").model_name: NeuralNetTorch(
module="MultiLayerPerceptron"
),
NeuralNetTorch(module="RadialBasisFunctionsNetwork").model_name: NeuralNetTorch(
module="RadialBasisFunctionsNetwork"
),
NeuralNetSk().model_name: NeuralNetSk(),
ConditionalNeuralProcess().model_name: ConditionalNeuralProcess(),
SupportVectorMachines().model_name: SupportVectorMachines(),
GaussianProcessTorch().model_name: GaussianProcessTorch(),
ConditionalNeuralProcess().model_name: ConditionalNeuralProcess(),
# currently not in use
# NeuralNetSk().model_name: NeuralNetSk(),
# GaussianProcess().model_name: GaussianProcess(),
# GaussianProcessMOGP().model_name: GaussianProcessMOGP(),
}
6 changes: 5 additions & 1 deletion autoemulate/emulators/conditional_neural_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def predict(self, X, return_std=False):
# needs to be float64 to pass estimator tests
# squeeze out batch dimension again so that score() etc. runs
mean, logvar = predictions

mean = mean[-X.shape[0] :].numpy().astype(np.float64).squeeze()
logvar = logvar[-X.shape[0] :].numpy().astype(np.float64).squeeze()

Expand All @@ -241,10 +242,13 @@ def predict(self, X, return_std=False):
var = np.exp(logvar) * (self._y_train_std**2)
logvar = np.log(var)

# if y is 1d, make predictions same shape
# make sure predictions have the same shape as y
if self.y_dim_ == 1:
mean = mean.ravel()
logvar = logvar.ravel()
else:
mean = mean.reshape(-1, self.output_dim_)
logvar = logvar.reshape(-1, self.output_dim_)

if return_std:
std = np.exp(0.5 * logvar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from autoemulate.utils import _suppress_convergence_warnings


class GaussianProcess(BaseEstimator, RegressorMixin):
class GaussianProcessSklearn(BaseEstimator, RegressorMixin):
"""Gaussian Process Emulator.
Wraps GaussianProcessRegressor from scikit-learn.
Expand Down
192 changes: 0 additions & 192 deletions autoemulate/emulators/neural_net_torch.py

This file was deleted.

2 changes: 0 additions & 2 deletions autoemulate/emulators/neural_networks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
from .base import TorchModule
from .get_module import get_module
36 changes: 0 additions & 36 deletions autoemulate/emulators/neural_networks/base.py

This file was deleted.

20 changes: 0 additions & 20 deletions autoemulate/emulators/neural_networks/get_module.py

This file was deleted.

Loading

0 comments on commit 84211df

Please sign in to comment.