Skip to content
This repository was archived by the owner on Dec 8, 2024. It is now read-only.

Directory structure #71

Merged
merged 4 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/source/qml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ Python API documentation
qml\.representations module
---------------------------

.. automodule:: qml.ml.representations.representations
.. automodule:: qml.representations
:members:
:undoc-members:
:show-inheritance:

qml\.kernels module
-------------------

.. automodule:: qml.ml.kernels
.. automodule:: qml.kernels
:members:
:undoc-members:
:show-inheritance:

qml\.distance module
--------------------

.. automodule:: qml.ml.kernels.distance
.. automodule:: qml.kernels.distance
:members:
:undoc-members:
:show-inheritance:

qml\.math module
----------------

.. automodule:: qml.ml.math
.. automodule:: qml.math
:members:
:undoc-members:
:show-inheritance:
Expand All @@ -55,15 +55,15 @@ qml\.Compound class
qml\.fchl module
----------------

.. automodule:: qml.ml.representations.fchl
.. automodule:: qml.representations.fchl
:members:
:show-inheritance:


qml\.wrappers module
--------------------

.. automodule:: qml.ml.kernels.wrappers
.. automodule:: qml.kernels.wrappers
:members:
:undoc-members:
:show-inheritance:
Expand Down
28 changes: 14 additions & 14 deletions docs/source/qml_examples/examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"from qml.ml.representations import *\n",
"from qml.representations import *\n",
"\n",
"# Dummy coordinates for a water molecule\n",
"coordinates = np.array([[1.464, 0.707, 1.056],\n",
Expand Down Expand Up @@ -121,7 +121,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"from qml.ml.kernels import gaussian_kernel\n",
"from qml.kernels import gaussian_kernel\n",
"\n",
"# Generate a numpy-array of the representation\n",
"X = np.array([c.representation for c in compounds])\n",
Expand Down Expand Up @@ -149,7 +149,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"from qml.ml.kernels import get_local_kernels_gaussian\n",
"from qml.kernels import get_local_kernels_gaussian\n",
"\n",
"# Assume the QM7 dataset is loaded into a list of Compound()\n",
"for compound in qm7:\n",
Expand Down Expand Up @@ -195,7 +195,7 @@
"metadata": {},
"outputs": [],
"source": [
"from qml.ml.representations import get_slatm_mbtypes\n",
"from qml.representations import get_slatm_mbtypes\n",
"\n",
"# Assume 'qm7' is a list of Compound() objects.\n",
"mbtypes = get_slatm_mbtypes([mol.nuclear_charges for compound in qm7])\n",
Expand All @@ -211,7 +211,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``local`` keyword in this example specifies that a local representation is produced. Alternatively the SLATM representation can be generate via the ``qml.ml.representations`` module:"
"The ``local`` keyword in this example specifies that a local representation is produced. Alternatively the SLATM representation can be generate via the ``qml.representations`` module:"
]
},
{
Expand All @@ -220,7 +220,7 @@
"metadata": {},
"outputs": [],
"source": [
"from qml.ml.representations import generate_slatm\n",
"from qml.representations import generate_slatm\n",
"\n",
"# Dummy coordinates\n",
"coordinates = ... \n",
Expand Down Expand Up @@ -249,7 +249,7 @@
"## Generating the FCHL representation\n",
"\n",
"The FCHL representation does not have an explicit representation in the form of a vector, and the kernel elements must be calculated analytically in a separate kernel function.\n",
"The syntax is analogous to the explicit representations (e.g. Coulomb matrix, BoB, SLATM, etc), but is handled by kernels from the separate ``qml.ml.representations.fchl`` module.\n",
"The syntax is analogous to the explicit representations (e.g. Coulomb matrix, BoB, SLATM, etc), but is handled by kernels from the separate ``qml.representations.fchl`` module.\n",
"\n",
"The code below show three ways to create the input representations for the FHCL kernel functions.\n",
"\n",
Expand Down Expand Up @@ -279,7 +279,7 @@
"The dimensions of the array should be ``(number_molecules, size, 5, size)``, where ``size`` is the\n",
"size keyword used when generating the representations. \n",
"\n",
"In addition to using the ``Compound`` class to generate the representations, FCHL representations can also be generated via the ``qml.ml.representations.fchl.generate_fchl_representation()`` function, using similar notation to the functions in the ``qml.ml.representations.*`` functions."
"In addition to using the ``Compound`` class to generate the representations, FCHL representations can also be generated via the ``qml.representations.fchl.generate_fchl_representation()`` function, using similar notation to the functions in the ``qml.representations.*`` functions."
]
},
{
Expand All @@ -288,7 +288,7 @@
"metadata": {},
"outputs": [],
"source": [
"from qml.ml.representations.fchl import generate_representation \n",
"from qml.representations.fchl import generate_representation \n",
"\n",
"# Dummy coordinates for a water molecule\n",
"coordinates = np.array([[1.464, 0.707, 1.056],\n",
Expand All @@ -314,7 +314,7 @@
"metadata": {},
"outputs": [],
"source": [
"from qml.ml.representations.fchl import generate_representation \n",
"from qml.representations.fchl import generate_representation \n",
"\n",
"# Dummy fractional coordinates\n",
"fractional_coordinates = np.array(\n",
Expand Down Expand Up @@ -372,7 +372,7 @@
"metadata": {},
"outputs": [],
"source": [
"from qml.ml.representations.fchl import get_local_kernels\n",
"from qml.representations.fchl import get_local_kernels\n",
"\n",
"# You can get kernels for multiple kernel-widths\n",
"sigmas = [2.5, 5.0, 10.0]\n",
Expand All @@ -396,7 +396,7 @@
"metadata": {},
"outputs": [],
"source": [
"from qml.ml.representations.fchl import get_local_symmetric_kernels\n",
"from qml.representations.fchl import get_local_symmetric_kernels\n",
"\n",
"# You can get kernels for multiple kernel-widths\n",
"sigmas = [2.5, 5.0, 10.0]\n",
Expand All @@ -420,8 +420,8 @@
"metadata": {},
"outputs": [],
"source": [
"from qml.ml.representations.fchl import get_atomic_kernels\n",
"from qml.ml.representations.fchl import get_atomic_symmetric_kernels"
"from qml.representations.fchl import get_atomic_kernels\n",
"from qml.representations.fchl import get_atomic_symmetric_kernels"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions docs/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ If you run the code below, you will read in the file ``qm7/0001.xyz`` (a methane
import qml

# Create the compound object mol from the file qm7/0001.xyz which happens to be methane
mol = qml.ml.Compound(xyz="qm7/0001.xyz")
mol = qml.Compound(xyz="qm7/0001.xyz")

# Generate and print a Coulomb matrix for compound with 5 atoms
mol.generate_coulomb_matrix(size=5, sorting="row-norm")
Expand Down Expand Up @@ -80,7 +80,7 @@ In order to save time you can import the entire QM7 dataset as ``Compound`` obje
# Import QM7, already parsed to QML
from tutorial_data import compounds

from qml.ml.kernels import gaussian_kernel
from qml.kernels import gaussian_kernel

# For every compound generate a Coulomb matrix or BoB
for mol in compounds:
Expand Down Expand Up @@ -114,7 +114,7 @@ With the kernel matrix and representations sorted out in the previous two exerci
:math:`\boldsymbol{\alpha} = (\mathbf{K} + \lambda \mathbf{I})^{-1} \mathbf{y}\label{eq:inv}`

One of the most efficient ways of solving this equation is using a Cholesky-decomposition.
QML includes a function named ``cho_solve()`` to do this via the math module ``qml.ml.math``.
QML includes a function named ``cho_solve()`` to do this via the math module ``qml.math``.
In this step it is convenient to only use a subset of the full dataset as training data (see below).
The following builds on the code from the previous step.
To save time, you can import the PBE0/def2-TZVP atomization energies for the QM7 dataset from the file ``tutorial_data.py``.
Expand All @@ -123,7 +123,7 @@ Extend your code from the previous step with the code below:

.. code:: python

from qml.ml.math import cho_solve
from qml.math import cho_solve
from tutorial_data import energy_pbe0

# Assign first 1000 molecules to the training set
Expand Down
6 changes: 5 additions & 1 deletion qml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@
from __future__ import absolute_import

from . import data
from . import ml
from . import models
from . import aglaia
from . import math
from . import kernels
from . import arad
from . import fchl
from . import representations

__author__ = "Anders S. Christensen"
__copyright__ = "Copyright 2016"
Expand Down
10 changes: 5 additions & 5 deletions qml/aglaia/aglaia.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@

try:
from qml.data import Compound
from qml.ml import representations as qml_rep
except ModuleNotFoundError:
raise ModuleNotFoundError("The module qml is required")
from qml import representations as qml_rep
except ImportError:
raise ImportError("The module qml is required")

try:
import tensorflow
except ModuleNotFoundError:
raise ModuleNotFoundError("Tensorflow 1.8 is required to run neural networks.")
except ImportError:
raise ImportError("Tensorflow 1.8 is required to run neural networks.")

class _NN(BaseEstimator):

Expand Down
2 changes: 1 addition & 1 deletion qml/ml/arad/__init__.py → qml/arad/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2017 Anders S. Christensen, Kristof T. Schutt, Stefan Chmiela
# Copyright (c) 2017 Anders S. Christensen and Felix A. Faber
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion qml/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2017 Anders S. Christensen, Kristof T. Schutt, Stefan Chmiela
# Copyright (c) 2017 Anders S. Christensen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
16 changes: 8 additions & 8 deletions qml/data/compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
import numpy as np
import collections

from ..ml.representations.alchemy import NUCLEAR_CHARGE
from ..representations.alchemy import NUCLEAR_CHARGE

from ..ml.representations import generate_coulomb_matrix
from ..ml.representations import generate_atomic_coulomb_matrix
from ..ml.representations import generate_bob
from ..ml.representations import generate_eigenvalue_coulomb_matrix
from ..ml.representations import generate_slatm
from ..representations import generate_coulomb_matrix
from ..representations import generate_atomic_coulomb_matrix
from ..representations import generate_bob
from ..representations import generate_eigenvalue_coulomb_matrix
from ..representations import generate_slatm

from ..ml.representations.fchl import generate_representation as generate_fchl_representation
from ..fchl import generate_representation as generate_fchl_representation

from ..ml.representations.facsf import fgenerate_acsf, fgenerate_acsf_and_gradients
from ..representations.facsf import fgenerate_acsf, fgenerate_acsf_and_gradients

class Compound(object):
""" The ``Compound`` class is used to store data from
Expand Down
2 changes: 1 addition & 1 deletion qml/data/dataprovider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2017 Anders S. Christensen, Kristof T. Schutt, Stefan Chmiela
# Copyright (c) 2017 Anders S. Christensen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion qml/data/xyzdataprovider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2017 Anders S. Christensen, Kristof T. Schutt, Stefan Chmiela
# Copyright (c) 2017 Anders S. Christensen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
23 changes: 23 additions & 0 deletions qml/fchl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# MIT License
#
# Copyright (c) 2017 Anders S. Christensen and Felix A. Faber
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from .fchl import *
2 changes: 1 addition & 1 deletion qml/ml/representations/fchl.py → qml/fchl/fchl.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from .ffchl_module import fget_atomic_kernels_fchl
from .ffchl_module import fget_atomic_symmetric_kernels_fchl

from .alchemy import get_alchemy
from ..representations.alchemy import get_alchemy

def generate_representation(coordinates, nuclear_charges,
max_size=23, neighbors=23, cut_distance = 5.0, cell=None):
Expand Down
2 changes: 1 addition & 1 deletion qml/ml/kernels/__init__.py → qml/kernels/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2017 Anders S. Christensen, Kristof T. Schutt, Stefan Chmiela
# Copyright (c) 2017 Anders S. Christensen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion qml/ml/math/__init__.py → qml/math/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2017 Anders S. Christensen, Kristof T. Schutt, Stefan Chmiela
# Copyright (c) 2017 Anders S. Christensen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
File renamed without changes.
File renamed without changes.
26 changes: 0 additions & 26 deletions qml/ml/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion qml/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2017 Anders S. Christensen, Kristof T. Schutt, Stefan Chmiela
# Copyright (c) 2017 Anders S. Christensen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions qml/models/kernelridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

import ase

from ..ml.representations import generate_coulomb_matrix
from ..ml.kernels import gaussian_kernel
from ..ml.math import cho_solve
from ..representations import generate_coulomb_matrix
from ..kernels import gaussian_kernel
from ..math import cho_solve
from .mlmodel import MLModel

class GenericKRR(MLModel):
Expand Down
Loading