Skip to content

Commit

Permalink
added experiment script
Browse files Browse the repository at this point in the history
  • Loading branch information
mamunm committed Mar 27, 2024
1 parent dd1869f commit b752ed6
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*.pyc
.coverage
*.egg-info/
*.db
23 changes: 23 additions & 0 deletions experiments/test_1/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from pathlib import Path
import sys

sys.path.append(str(Path(__file__).parents[2]))

from src.mobo_qm9 import MOBOQM9, MOBOQM9Parameters
from src.utils import plot_results

params = MOBOQM9Parameters(featurizer="CM",
kernel="RBF",
surrogate_model="GaussianProcess",
acq_func="qEHVI",
targets=["gap", "mu"],
target_bools=[True, True],
num_total_points=100,
num_seed_points=10,
n_iters=100,
num_candidates=10)

moboqm9 = MOBOQM9(params)
moboqm9.run_optimization()
plt = plot_results(moboqm9.dataframe)
plt.show()
1 change: 1 addition & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""init file."""
10 changes: 4 additions & 6 deletions src/mobo_qm9.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from botorch.utils.multi_objective.box_decompositions import DominatedPartitioning
from botorch.models import ModelListGP, SingleTaskGP
import gpytorch
from gpytorch.kernels import RBFKernel, MaternKernel, TanimotoKernel
from gpytorch.kernels import RBFKernel, MaternKernel
from botorch.fit import fit_gpytorch_mll
from botorch.models.transforms.input import Normalize
from botorch.models.transforms.output import Standardize
from botorch.models.transforms.outcome import Standardize

from .data.cm_featurizer import get_coulomb_matrix
from .acquisition_functions import optimize_qEHVI, optimize_qNEHVI
Expand All @@ -33,7 +33,7 @@ class MOBOQM9Parameters(NamedTuple):
n_iters: Number of iterations. Default is 20.
"""
featurizer: Literal["ECFP", "CM", "ACSF"]
kernel: Literal["RBF", "Matern", "Tanimoto"]
kernel: Literal["RBF", "Matern"]
surrogate_model: Literal["GaussianProcess", "RandomForest"]
acq_func: Literal["qEHVI", "qNEHVI", "random"]
targets: List[str]
Expand Down Expand Up @@ -93,8 +93,6 @@ def get_surrogate_model(self):
kernel = RBFKernel()
elif self.params.kernel == 'Matern':
kernel = MaternKernel()
elif self.params.kernel == 'Tanimoto':
kernel = TanimotoKernel()
else:
raise ValueError("Unsupported kernel type. Supported types are 'RBF', 'Matern', and 'Tanimoto'.")

Expand Down Expand Up @@ -226,7 +224,7 @@ def validate_params(self):
params: Parameters for the MOBOQM9 model.
"""
assert self.params.featurizer in ["ECFP", "CM", "ACSF"], "Featurizer must be one of ECFP, CM, or ACSF."
assert self.params.kernel in ["RBF", "Matern", "Tanimoto"], "Kernel must be one of RBF, Matern, or Tanimoto."
assert self.params.kernel in ["RBF", "Matern", "Tanimoto"], "Kernel must be one of RBF, Matern."
assert self.params.surrogate_model in ["GaussianProcess", "RandomForest"], "Surrogate model must be one of GaussianProcess, or RandomForest."
assert self.params.acq_func in ["qEHVI", "qNEHVI", "random"], "Acquisition function must be one of qEHVI, or qNEHVI, or random."
assert len(self.params.targets) == len(self.params.target_bools), "Number of targets must equal number of target booleans."
Expand Down
11 changes: 11 additions & 0 deletions src/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def plot_results(df):
"""
Plots the results for the MOBOQM9 model.
args:
df: Results for the MOBOQM9 model.
returns:
matplotlib.pyplot.figure: Figure for the MOBOQM9 model.
"""
pass

0 comments on commit b752ed6

Please sign in to comment.