dscribe.descriptors.matrixdescriptor module¶
Copyright 2019 DScribe developers
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- class dscribe.descriptors.matrixdescriptor.MatrixDescriptor(n_atoms_max, permutation='sorted_l2', sigma=None, seed=None, flatten=True, sparse=False)[source]¶
Bases:
dscribe.descriptors.descriptor.Descriptor
A common base class for two-body matrix-like descriptors.
- Parameters
n_atoms_max (int) – The maximum nuber of atoms that any of the samples can have. This controls how much zeros need to be padded to the final result.
permutation (string) –
Defines the method for handling permutational invariance. Can be one of the following:
none: The matrix is returned in the order defined by the Atoms.
sorted_l2: The rows and columns are sorted by the L2 norm.
eigenspectrum: Only the eigenvalues are returned sorted by their absolute value in descending order.
random: The rows and columns are sorted by their L2 norm after applying Gaussian noise to the norms. The standard deviation of the noise is determined by the sigma-parameter.
sigma (float) – Provide only when using the random-permutation option. Standard deviation of the gaussian distributed noise determining how much the rows and columns of the randomly sorted matrix are scrambled.
seed (int) – Provide only when using the random-permutation option. A seed to use for drawing samples from a normal distribution.
flatten (bool) – Whether the output of create() should be flattened to a 1D array.
sparse (bool) – Whether the output should be a sparse matrix or a dense numpy array.
- create_single(system)[source]¶
- Parameters
system (
ase.Atoms
|System
) – Input system.- Returns
- The zero padded matrix either as a 2D array or as
a 1D array depending on the setting self._flatten.
- Return type
ndarray
- get_eigenspectrum(matrix)[source]¶
Calculates the eigenvalues of the matrix and returns a list of them sorted by their descending absolute value.
- Parameters
matrix (np.ndarray) – The matrix to sort.
- Returns
A list of eigenvalues sorted by absolute value.
- Return type
np.ndarray
- abstract get_matrix(system)[source]¶
Used to get the final matrix for this descriptor.
- Parameters
system (
ase.Atoms
|System
) – Input system.- Returns
The final two-dimensional matrix for this descriptor.
- Return type
np.ndarray
- get_number_of_features()[source]¶
Used to inquire the final number of features that this descriptor will have.
- Returns
Number of features for this descriptor.
- Return type
- sort(matrix)[source]¶
Sorts the given matrix by using the L2 norm.
- Parameters
matrix (np.ndarray) – The matrix to sort.
- Returns
The sorted matrix.
- Return type
np.ndarray
- sort_randomly(matrix, sigma)[source]¶
Given a coulomb matrix, it adds random noise to the sorting defined by sigma. For sorting, L2-norm is used.
- Parameters
matrix (np.ndarray) – The matrix to randomly sort.
- sigma:
- float: Width of gaussian distributed noise determining how much the
rows and columns of the randomly sorted coulomb matrix are scrambled.
- Returns
The randomly sorted matrix.
- Return type
np.ndarray