ciderpress.models.dft_kernel
The DFTKernel
- class ciderpress.models.dft_kernel.DFTKernel(kernel, feature_list, mode, multiplicative_baseline, additive_baseline=None, ctrl_tol=1e-05, ctrl_nmax=None, component=None)
This class is used to evaluate kernel functions, including the baseline X/C energies, for use in the MOLGP Gaussian process models.
Raw descriptors are denoted X0. Transformed descriptors are denoted as X1. Nctrl is the number of control points for the kernel. N0 is the number of raw features. N1 is the number of transformed features.
- mode
One of (SEP, POL, OSPOL, SSPOL, NPOL).
- Type:
str
- X1ctrl
Control points for kernel.
- Type:
Nctrl, N1
Note on the baselines: Two baseline function callables are passed to __init__: multiplicative_baseline and additive_baseline. The ML part of the XC energy is
multiplicative_baseline * gp + additive_baseline
, wheregp
is the raw output of the Gaussian process. Seeciderpress.dft.baselines
for details on the options for this argument.Some notation notes:
k: kernel
dkdX0T: kernel derivative with respect to raw features.
m: Multiplicative baseline
a: Additive baseline
dm: Derivative of multiplicative baseline wrt features
da: Derivative of additive baseline wrt features
SEP array shapes:
k: (Nctrl, nspin, Nsamp)
m and a: (nspin, Nsamp)
dkdX0T: (Nctrl, nspin, N0, Nsamp)
dm and da: (nspin, N0, Nsamp)
NPOL and POL array shapes:
k: (Nctrl, Nsamp)
m and a: Nsamp
dkdX0t: (Nctrl, nspin, N0, Nsamp)
dm and da: (N0, nspin, Nsamp)
- Parameters:
kernel (ciderpress.models.kernels.DiffKernelMixin) – An sklearn kernel with the added utility of being differentiable with respect to its inputs via the function get_k_and_deriv
feature_list (ciderpress.dft.transform_data.FeatureList) – A list of transformations to be performed on the raw features before feeding them into the kernel function.
mode (str) – Whether the kernel is part of the exchange (“x”), correlation (“c”), or exchange-correlation (“xc”) energy.
multiplicative_baseline (callable) – This function takes in the raw features X0T and returns the baseline energy by which the ML model should be multiplied.
additive_baseline (callable) – This function takes in the raw features X0T and returns the baseline energy that should be added to the model
- get_k(X0T)
Compute the kernel function between the input samples
X0T
and the control points stored in thisDFTKernel
object.- Parameters:
X0T (np.ndarray) – Shape (nspin, nfeat, nsamp), raw feature vector
- Returns:
- Shape (nctrl, nspin, nsamp) for SEP mode, shape
(nctrl, nsamp) for NPOL and POL modes. The kernel function evaluated between the control points and the sample points.
- Return type:
(np.ndarray)
- get_k_and_deriv(X0T)
Compute the kernel function between the input samples
X0T
and the control points stored in thisDFTKernel
object, along with the derivative with respect to the input samples.- Parameters:
X0T (np.ndarray) – Shape (nspin, nfeat, nsamp), raw feature vector
- Returns:
- Shape (nctrl, nspin, nsamp) for SEP mode, shape
(nctrl, nsamp) for NPOL and POL modes. The kernel function evaluated between the control points and the sample points.
- (np.ndarray): Shape (nctrl, nspin, N0, nsamp) for all modes.
The derivative of the kernel with result to the sample inputs.
- Return type:
(np.ndarray)
- get_kctrl()
Compute the covariance matrix of the control points.
- map(mapping_plan)
Must only be called after the model is trained. This function creates a MappedDFTKernel that evaluates the contribution to the XC energy from
self
, as well as the derivative of that XC energy contribution with respect to the raw features X0. SeeMappedDFTKernel
docs for details.- Parameters:
mapping_plan (callable) – A function that takes a DFTKernel object and returns a list of
FuncEvaluator
instances calledfevals
, that represents the functions that must be evaluated to compute the XC energy contribution ofself
.
- class ciderpress.models.dft_kernel.DFTKernel2(kernel, feature_list, mode, multiplicative_baseline, additive_baseline=None, ctrl_tol=1e-05, ctrl_nmax=None, component=None)
DFTKernel2 is a modification of the DFTKernel object to use a different approach to constructing the baseline X(C) energy. DFTKernel2 is build on KernelEvalBase2, which uses libxc to evaluate XC baselines, as opposed to KernelEvalBase, which uses the native functions in
ciderpress.dft.baselines
.- map(mapping_plan)
See
DFTKernel.map
.