dscribe.kernels.rematchkernel 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.kernels.rematchkernel.REMatchKernel(alpha=0.1, threshold=1e-06, metric='linear', gamma=None, degree=3, coef0=1, kernel_params=None, normalize_kernel=True)[source]

Bases: dscribe.kernels.localsimilaritykernel.LocalSimilarityKernel

Used to compute a global similarity of structures based on the regularized-entropy match (REMatch) kernel of local atomic environments in the structure. More precisely, returns the similarity kernel K as:

\[ \begin{align}\begin{aligned}\DeclareMathOperator*{\argmax}{argmax} K(A, B) &= \mathrm{Tr} \mathbf{P}^\alpha \mathbf{C}(A, B)\\\mathbf{P}^\alpha &= \argmax_{\mathbf{P} \in \mathcal{U}(N, N)} \sum_{ij} P_{ij} (1-C_{ij} +\alpha \ln P_{ij})\end{aligned}\end{align} \]

where the similarity between local atomic environments \(C_{ij}\) has been calculated with the pairwise metric (e.g. linear, gaussian) defined by the parameters given in the constructor.

For reference, see:

“Comparing molecules and solids across structural and alchemical space”, Sandip De, Albert P. Bartók, Gábor Csányi and Michele Ceriotti, Phys. Chem. Chem. Phys. 18, 13754 (2016), https://doi.org/10.1039/c6cp00415f

Parameters
  • alpha (float) – Parameter controlling the entropic penalty. Values close to zero approach the best-match solution and values towards infinity approach the average kernel.

  • threshold (float) – Convergence threshold used in the Sinkhorn-algorithm.

  • metric (string or callable) – The pairwise metric used for calculating the local similarity. Accepts any of the sklearn pairwise metric strings (e.g. “linear”, “rbf”, “laplacian”, “polynomial”) or a custom callable. A callable should accept two arguments and the keyword arguments passed to this object as kernel_params, and should return a floating point number.

  • gamma (float) – Gamma parameter for the RBF, laplacian, polynomial, exponential chi2 and sigmoid kernels. Interpretation of the default value is left to the kernel; see the documentation for sklearn.metrics.pairwise. Ignored by other kernels.

  • degree (float) – Degree of the polynomial kernel. Ignored by other kernels.

  • coef0 (float) – Zero coefficient for polynomial and sigmoid kernels. Ignored by other kernels.

  • kernel_params (mapping of string to any) – Additional parameters (keyword arguments) for kernel function passed as callable object.

  • normalize_kernel (boolean) – Whether to normalize the final global similarity kernel. The normalization is achieved by dividing each kernel element \(K_{ij}\) with the factor \(\sqrt{K_{ii}K_{jj}}\)

get_global_similarity(localkernel)[source]

Computes the REMatch similarity between two structures A and B.

Parameters

localkernel (np.ndarray) – NxM matrix of local similarities between structures A and B, with N and M atoms respectively.

Returns

REMatch similarity between the structures A and B.

Return type

float