-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
General improvements and addition of Gaussian process regression
- ml4chem/data/parser.py: improved FakeCalculator class and its docstrings. - ml4chem/models/kernelridge.py: * New `class_name` parameter is saved to operate with universal loading of models. * get_kernel_matrix() function can handle more input cases. * Improvement in docstrings. - ml4chem/potentials.py: universal loading of models. - setup.py: now the `ml4chem` command line tool is installed with pip. - ml4chem/models/gaussian_process.py: the new gaussian process regression model for ml4chem. It uses the KernelRidge class in the kernelridge module as a base class to then compute the extra step referring to the inference variance. This is related to #18. - Updated examples/.
- Loading branch information
Showing
18 changed files
with
1,480 additions
and
882 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import logging | ||
import sys | ||
|
||
sys.path.append("../../") | ||
from ase.io import Trajectory | ||
from dask.distributed import Client, LocalCluster | ||
from ml4chem import Potentials | ||
|
||
|
||
def main(): | ||
"""docstring for main""" | ||
|
||
# Load the images with ASE | ||
images = Trajectory("cu_training.traj") | ||
|
||
calc = Potentials.load( | ||
model="cu_training.ml4c", | ||
params="cu_training.params", | ||
preprocessor="cu_training.scaler", | ||
) | ||
|
||
# Passage of fingerprint database with reference space | ||
calc.reference_space = "fingerprints.db" | ||
|
||
for atoms in images: | ||
energy = calc.get_potential_energy(atoms) | ||
print("ML4Chem predicted energy = {}".format(energy)) | ||
print(" DFT energy = {}".format(atoms.get_potential_energy())) | ||
|
||
|
||
if __name__ == "__main__": | ||
logging.basicConfig( | ||
filename="cu_inference.log", | ||
level=logging.INFO, | ||
format="%(filename)s:%(lineno)s %(levelname)s:%(message)s", | ||
) | ||
cluster = LocalCluster(n_workers=8, threads_per_worker=2) | ||
client = Client(cluster, asyncronous=True) | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import sys | ||
from ase.io import Trajectory | ||
from dask.distributed import Client, LocalCluster | ||
|
||
sys.path.append("../../") | ||
from ml4chem import Potentials | ||
from ml4chem.fingerprints import Gaussian | ||
from ml4chem.models.gaussian_process import GaussianProcess | ||
from ml4chem.utils import logger | ||
|
||
|
||
def train(): | ||
# Load the images with ASE | ||
images = Trajectory("cu_training.traj") | ||
|
||
# Arguments for fingerprinting the images | ||
normalized = True | ||
batch_size = 160 | ||
|
||
calc = Potentials( | ||
fingerprints=Gaussian( | ||
cutoff=6.5, normalized=normalized, save_preprocessor="cu_training.scaler" | ||
), | ||
#model=GaussianProcess(batch_size=batch_size), | ||
model=GaussianProcess(), | ||
label="cu_training", | ||
) | ||
|
||
calc.train(training_set=images) | ||
|
||
|
||
if __name__ == "__main__": | ||
logger() | ||
cluster = LocalCluster() | ||
client = Client(cluster, asyncronous=True) | ||
train() |
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.