Core functionalities

class codpy.core.op[source]

Bases: object

projection(y, z, fx, reg=[], **kwargs)[source]

Performs projection in kernel regression for efficient computation, targeting a lower sampling space. .. note:

The performance of the function depends on two ingredients:

* ``kernel`` function
* ``map``

Example

With NumPy arrays

>>> xtrain = np.random.randn(100, 1)
>>> xtest = np.random.randn(100, 1)
>>> fx_train = x * 2
>>> fx_test = z * 2
>>> fx_test_pred = projection(xtrain, xtrain, xtest, fx_train,
kernel_fun = "tensornorm", map = "unitcube",
       polynomial_order=2)

With pandas DataFrames

>>> x_train_df = pd.DataFrame([...])
>>> y_train_df = pd.DataFrame([...])
>>> z_test_df = pd.DataFrame([...])
>>> fx_train_df = pd.DataFrame([...])
>>> projected_responses = projection(x_train_df, y_train_df, z_test_df, fx_train_df, kernel_fun = "tensornorm", map = "unitcube",
       polynomial_order=2)
extrapolation(z, fx=[], **kwargs)[source]

Performs extrapolation in the context of kernel regression.

This method leverages the kernel regression framework to extrapolate values between data points. .. note:

The performance of the function depends on two ingredients:

* ``kernel`` function
* ``map``
interpolation(z, fx=[], **kwargs)[source]

Performs interpolation in the context of kernel regression.

This method leverages the kernel regression framework to interpolate values between data points. .. note:

The performance of the function depends on two ingredients:

* ``kernel`` function
* ``map``
gradient_denoiser(z, fx=[], epsilon=1e-09, **kwargs)[source]

A function for performing least squares regression penalized by the norm of the gradient, induced by a positive definite (PD) kernel.

This functioon initializes with various parameters and sets up a regression framework that includes regularization based on the gradient’s magnitude. It is designed to work with gradient norms induced by a PD kernel. :returns: The denoised output for the input data.

Example:

Initialize the denoiser with input data ‘x’ and optional parameters

>>> xtrain = np.random.randn(100, 1)
>>> xtest = np.random.randn(100, 1)
>>> fx_train = x * 2
>>> fx_test = z * 2

# Perform denoising on the input data or new data points ‘z’ op.denoiser(xtrain, xtest, fx_train, kernel_fun = “maternnorm”, map = “standardmean”)

norm(y, z, fx=[], **kwargs)[source]

Calculate the kernel-induced norm based on the provided matrices.

This function computes a norm projection using the kernel initialization parameters. It supports flexible argument input through keyword arguments.

Parameters:
  • x (list, optional) – The first matrix. Defaults to an empty list.

  • y (list, optional) – The second matrix. Defaults to a list containing x.

  • z (list, optional) – The third matrix. Defaults to an empty list.

  • fx (list, optional) – The fourth matrix. Defaults to an empty list.

Note

The performance of the function depends on two ingredients:

  • kernel function

  • map

coefficients(y, fx=[], **kwargs) ndarray[source]

Computes the regressors or coefficients for kernelized regression, using a specified PD kernel.

This method initializes the kernel function with the given parameters and then computes the regression coefficients based on the input datasets.

Parameters:
  • x (np.array) – The input data points for which the regression coefficients are computed.

  • y (np.array) – Internal parameter, can be y = x.

  • fx (np.array, optional) – Responses associated with ‘x’.

Returns:

The computed regression coefficients or regressors that model the relationship between the input data ‘x’ and the target ‘y’.

Return type:

np.array

Available Kernels:

  • 'gaussian': Gaussian kernel for smooth, continuous functions.

  • 'tensornorm': Tensor norm kernel suitable for multidimensional data.

  • 'absnorm': Absolute norm kernel for robust performance in varied datasets.

  • 'matern': Matérn kernel useful in spatial statistics.

  • 'multiquadricnorm': Multi-quadric norm kernel for flexible shape adaptation.

  • 'multiquadrictensor': Multi-quadric tensor kernel, a tensor-based variant offering flexible shape adaptation.

  • 'sincardtensor': Sinc cardinal tensor kernel, suitable for periodic and oscillatory data.

  • 'sincardsquaretensor': Sinc cardinal square tensor kernel, enhancing the sinc cardinal tensor kernel for certain data types.

  • 'dotproduct': Dot product kernel, useful for linear classifications and regressions.

  • 'gaussianper': Gaussian periodic kernel, ideal for modeling periodic functions.

  • 'maternnorm': Matérn norm kernel, a variation of the Matérn kernel for normalized spaces.

  • 'scalarproduct': Scalar product kernel, a simple yet effective kernel for dot products.

Available Maps:

  • 'linear': Linear map for straightforward transformations.

  • 'affine': Affine map for linear transformations with translation.

  • 'log': Logarithmic map for non-linear scaling.

  • 'exp': Exponential map for rapidly increasing scales.

  • 'scalestd': Standard scaling map that normalizes data by removing the mean and scaling to unit variance.

  • 'erf': Error function map, useful for data normalization with a non-linear scale.

  • 'erfinv': Inverse error function map, providing the inverse transformation of the error function.

  • 'scalefactor': Scaling factor map that applies a uniform scaling defined by a bandwidth or scale factor.

  • 'bandwidth': Helper for setting the scale factor map with a specified bandwidth, typically used in kernel methods.

  • 'grid': Grid map that projects data onto a grid, useful for discretizing continuous variables or spatial data.

  • 'unitcube': Unit cube map that scales data to fit within a unit cube, ensuring all features are within the range [0,1].

  • 'meandistance': Mean distance map that scales data based on the mean distance between data points.

  • 'mindistance': Minimum distance map that scales data based on the minimum distance between data points.

  • 'standardmin': Standard minimum map pipeline combining minimum distance scaling with other transformations.

  • 'standardmean': Standard mean map pipeline combining mean distance scaling with other transformations.

Knm(y, fy=[], **kwargs) ndarray[source]

Computes the kernel matrix induced by a positive definite (pd) kernel.

This method calculates the kernel matrix k(x_i,y_j) using the input kernel function.

Parameters:
  • x (numpy.ndarray) – Input data points for the gradient computation. np.array of size N , D.

  • y (numpy.ndarray) – Secondary data points used in the kernel computation. np.array of size M , D.

  • fx (numpy.ndarray) – optional-Function values or responses at the data points in x. np.array of size M , Df.

Returns:

matrix np.array of size (NxM) The computed kernel matrix, representing the kernel-induced distances or similarities between the data points in ‘x’ and ‘y’. - prod(Knm(x,y),fx) else. This allow performance and memory optimizations.

Return type:

  • if fx is empty

Knm_inv(y, fx=[], epsilon=1e-09, reg_matrix=[], **kwargs)[source]
Parameters:
  • x (numpy.ndarray) – Input data points for the gradient computation. np.array of size N , D.

  • y (numpy.ndarray) – Secondary data points used in the kernel computation. np.array of size M , D.

  • fx (numpy.ndarray) – optional-Function values or responses at the data points in x. np.array of size M , Df.

Returns:

  • if fx is empty: matrix np.array of size (NxM), that is the least square inverse of Knm(x,y).
    • prod(Knm_inv(x,y),fx) else. This allow performance and memory optimizations. The output corresponds then to the coefficient of fx in the kernel induced basis.

  • else:
    • if fx is empty: matrix np.array of size (NxM), that corresponds to the least square computation (Knm(y,x)Knm(x,y)+reg)^{-1}Knm(y,x).

    • prod(Knm_inv(x,y),fx) else. This allow performance and memory optimizations. The output corresponds then to the coefficient of fx in the kernel induced basis.

Return type:

  • if reg is empty

Dnm(y, distance=None, **kwargs) ndarray[source]

Computes a distance matrix induced by a positive definite (pd) kernel.

This function calculates the distance matrix between sets of data points x and y based on a specified pd kernel.

Parameters:
  • x (np.array) – The first set of data points.

  • y (np.array) – The second set of data points. If not provided, defaults to x.

  • distance (function, optional) – a name of distance function.

Returns:

A distance matrix representing the distances between each pair of points in x and y as induced by the pd kernel.

Return type:

np.array

discrepancy_error(z: array, disc_type='raw', **kwargs)[source]
norm_projection(z: array, fx: array | None = None, **kwargs)[source]
class codpy.core.misc[source]

Bases: object

Miscellaneous kernel functions or classes.

distance_labelling(y, label=None, distance=None, maxmin: str = 'min', axis: int = 1, **kwargs) ndarray[source]

Computes and labels distances using a kernel-induced distance matrix.

This function calculates the distance matrix between two sets of data points (x and y) using a specified kernel function. It then labels these distances based on either the softmax or softmin indices, depending on the ‘max’ parameter in kwargs.

Parameters:
  • x (np.array) – The first set of data points.

  • y (np.array) – The second set of data points.

  • axis (int, optional) – The axis along which to compute the distances. Default is 1.

  • max (bool, optional) – Determines the type of labelling: - If True, uses softmax labelling. - If False (default), uses softmin labelling. :param kernel_fun: The name of the kernel function to use. Options include 'gaussian', 'tensornorm', etc.

Returns:

An array of labelled distances between the data points in x and y.

Return type:

np.array

discrepancy(z: array, y: array | None = None, disc_type='raw', **kwargs)[source]
class discrepancy_functional(x, fx, kernel_fun='tensornorm', map='unitcube', polynomial_order=2, regularization: float = 1e-08, reg: ndarray = [], rescale=False, **kwargs)[source]

Bases: object

A kernel-induced discrepancy between two distributions.

Discrepancy is a non-parametric method to test the equality of two distributions. It’s computed in a Reproducing Kernel Hilbert Space (RKHS) using a specified kernel function.

Attributes: Nx (int): The number of samples in the first distribution ‘x’. x (array-like): The first distribution for which MMD is to be computed. Kxx (float): The kernel-induced distance computed within ‘x’.

Parameters:
  • x (array-like) – The first input distribution.

  • y (array-like, optional) – The second input distribution. If not provided, it defaults to an empty list.

  • **kwargs – Additional keyword arguments for the kernel function.

eval(ys, **kwargs)[source]

Computes the MMD between the distribution ‘ys’ and the initial distribution ‘x’.

Example

Define two distributions

>>> x = np.array([...])
>>> y = np.array([...])

Initialize discrepancy functional for ‘x’

>>> discrepancy = discrepancy_functional(x)

Compute MMD between ‘x’ and ‘y’

>>> discrepancy_value = discrepancy.eval(y)
__init__(x, fx, kernel_fun='tensornorm', map='unitcube', polynomial_order=2, regularization: float = 1e-08, reg: ndarray = [], rescale=False, **kwargs)[source]

Args:

Parameters:
  • kernel_fun (str, optional) – The name of the kernel function to use. Options include 'gaussian', 'tensornorm', etc.

  • map (str, optional) – The name of the mapping function to apply. Options include 'linear', 'affine', etc.

  • polynomial_order (float, optional) – The polynomial order for the kernel function. Defaults to 2.

  • regularization (numpy.ndarray, optional) – Regularization parameter for the kernel. Defaults to 1e-8.

  • rescale (bool, optional) – Whether to rescale the data.

  • rescale_params (dict, optional) – Parameters for data rescaling. Defaults to {'max': 1000, 'seed': 42}.

  • kwargs (dict) – Arbitrary keyword arguments.

eval(ys, fx, Kinv=None, kernel_fun='tensornorm', map='unitcube', polynomial_order=2, regularization=1e-08, reg=[], rescale=False, **kwargs)[source]

Args:

Parameters:
  • kernel_fun (str, optional) – The name of the kernel function to use. Options include 'gaussian', 'tensornorm', etc.

  • map (str, optional) – The name of the mapping function to apply. Options include 'linear', 'affine', etc.

  • polynomial_order (float, optional) – The polynomial order for the kernel function. Defaults to 2.

  • regularization (numpy.ndarray, optional) – Regularization parameter for the kernel. Defaults to 1e-8.

  • rescale (bool, optional) – Whether to rescale the data.

  • rescale_params (dict, optional) – Parameters for data rescaling. Defaults to {'max': 1000, 'seed': 42}.

  • kwargs (dict) – Arbitrary keyword arguments.

class codpy.core.diffops[source]

Bases: object

nabla_Knm(y: array, fy=[], **kwargs)[source]

Args:

nabla(z: array, y=None, fx=[], **kwargs)[source]

Compute the kernel-induced gradient of a function.

Parameters:
  • x (numpy.ndarray or pandas.DataFrame) – Input data points for the gradient computation.

  • y (numpy.ndarray or pandas.DataFrame) – Secondary data points used in the kernel computation.

  • z (numpy.ndarray or pandas.DataFrame) – Tertiary data points used in the kernel computation.

  • fx (numpy.ndarray or pandas.DataFrame) – Function values or responses at the data points in x.

Returns:

The computed gradient of the function.

Return type:

numpy.ndarray

Example

>>> x = np.random.randn(100, 1)
>>> z = np.random.randn(100, 1)
>>> fx = x * 2
>>> fz = z * 2
>>> gradient = diffops.nabla(x,x,z,fx)
nabla_inv(z, y=None, fz=[], **kwargs)[source]

Compute the inverse of the kernel-induced gradient operation.

Parameters:
  • x (numpy.ndarray or pandas.DataFrame) – Input data points.

  • y (numpy.ndarray or pandas.DataFrame) – Secondary data points.

  • z (numpy.ndarray or pandas.DataFrame) – Tertiary data points.

  • fz (numpy.ndarray, optional) – The vector field for the inverse gradient computation.

Returns:

The computed inverse gradient of the vector field.

Return type:

numpy.ndarray

Example

>>> x_data = np.array([...])
>>> y_data = np.array([...])
>>> z_data = np.array([...])
>>> vector_field = np.array([...])
>>> inv_gradient = nabla_inv(x_data, y_data, z_data, fz=vector_field)
nablaT(y, z, fz, **kwargs)[source]

Compute the divergence of a vector field using a kernel-induced method.

This function calculates the divergence (nabla transpose) of a vector field in the context of kernel methods.

Parameters:
  • class (fz) – numpy.ndarray: The input data points where the divergence is calculated.

  • classnumpy.ndarray: Secondary data points used in the kernel computation.

  • classnumpy.ndarray: Tertiary data points used in the kernel computation.

  • classnumpy.ndarray: The vector field for which the divergence is computed. Defaults to an empty list.

Returns:

numpy.ndarray: The computed divergence of the vector field at each point in x.

Return type:

class

Example

Example usage with NumPy arrays

>>> x_data = np.array([...])
>>> y_data = np.array([...])
>>> z_data = np.array([...])
>>> vector_field = np.array([...])
>>> divergence = nablaT(x_data, y_data, z_data, fz=vector_field)
nablaT_inv(z, y=None, fx=[], **kwargs)[source]

Compute the inverse of the transposed gradient operation.

Parameters:
  • x (numpy.ndarray or pandas.DataFrame) – Input data points.

  • y (numpy.ndarray or pandas.DataFrame) – Secondary data points.

  • z (numpy.ndarray or pandas.DataFrame) – Tertiary data points.

  • fx (numpy.ndarray or pandas.DataFrame) – Function values or responses at the data points.

Returns:

The computed inverse of the transposed gradient.

Return type:

numpy.ndarray

Example

>>> x_data = np.array([...])
>>> y_data = np.array([...])
>>> z_data = np.array([...])
>>> fx_data = np.array([...])
>>> inv_transpose_gradient = nablaT_inv(x_data, y_data, z_data, fx_data)
nablaT_nabla(y, fx=[], **kwargs)[source]

Compute the kernel-induced discrete Laplace operator.

This function calculates the discrete Laplace operator using a kernel method. It computes this operator as the dot product of the transposed gradient vector and the gradient vector, which is consistent with a differential operator that resembles the Laplace operator in its behavior.

Args:

x (numpy.ndarray or pandas.DataFrame): Input data points for the Laplace operator computation. y (numpy.ndarray or pandas.DataFrame): Secondary data points used in the kernel computation. fx (numpy.ndarray or pandas.DataFrame): Function values or responses at the data points.

class:numpy.ndarray: The computed discrete Laplace operator values for each point in x.

Note:

The discrete Laplace operator computed here is not consistent with the “true” Laplace operator, but instead aligns with another differential operator, described as (-

abla cdot ( abla fmu)).

Example:

Example usage with NumPy arrays

>>> x_data = np.array([...])
>>> y_data = np.array([...])
>>> fx_data = np.array([...])
>>> laplace_operator = nablaT_nabla(x_data, y_data, fx_data)
nablaT_nabla_inv(y, fx=[], **kwargs)[source]

Args:

Leray_T(y, fx=[], **kwargs)[source]
Leray(y, fx=[], **kwargs)[source]

Compute the Leray operator for a given set of input matrices.

Parameters:
  • x (numpy.ndarray or pandas.DataFrame) – Input data points.

  • y (numpy.ndarray or pandas.DataFrame) – Secondary data points.

  • fx (numpy.ndarray or pandas.DataFrame) – Function values or responses at the data points.

  • **kwargs (dict) – Arbitrary keyword arguments.

Returns:

The result of the Leray operator computation.

Return type:

numpy.ndarray or pandas.DataFrame

Example

>>> x_data = np.array([...])
>>> y_data = np.array([...])
>>> fx_data = np.array([...])
>>> leray_result = Leray(x_data, y_data, fx_data)
hessian(z, fx=[], **kwargs) ndarray[source]

Compute the kernel-induced Hessian matrix of a function

Parameters:
  • x (numpy.ndarray or pandas.DataFrame) – Input data points where the Hessian matrix is calculated.

  • z (numpy.ndarray or pandas.DataFrame) – Tertiary data points used in the kernel computation.

  • fx (numpy.ndarray or pandas.DataFrame) – Function values or responses at the data points in x.

Returns:

The computed Hessian matrix of the function.

Return type:

numpy.ndarray

Note

The function computes the Hessian matrix for each input data point. If the ‘fx’ parameter is provided, the function computes a modified Hessian matrix using this additional information.

Example

>>> x_data = np.array([...])
>>> z_data = np.array([...])
>>> fx_data = np.array([...])
>>> hessian_matrix = hessian(x_data, z_data, fx_data)
class codpy.core.factories[source]

Bases: object

A class to manipulate built-in codpy factories.

Note: two kinds of factories are exhibited

Users can overload these factories to add their own kernels and map, see kernel_overloading.my_kernel_overloading()

check_map_strings()[source]

Simply check that the string, or list of strings, are keys for the dictionary factories.get_map_factory_keys()

Parameters:

strings – (str or list).

check_kernel_strings()[source]

Simply check that the string, or list of strings, are keys in the dictionary factories.get_kernel_factory_keys()

Parameters:

strings – (str or list).

get_kernel_factory()[source]
get_kernel_factory_keys()[source]
get_map_factory()[source]
get_map_factory_keys()[source]
class codpy.core.kernel_interface[source]

Bases: object

Miscellaneous instructions to instruct the C++ interface.

set_verbose()[source]

Produce a diagnosis file “output.xml” to debug, profile or audit the C++ core.

set_num_threads() None[source]

Limit the number of threads used by the C++ core.

rescale(y=[], z=[], max=None, seed=42, **kwargs)[source]

Intruct the kernel map to fit its parameters in order to match the variables \(x,y,z\).

Parameters:
  • x (numpy.ndarray or pandas.DataFrame) – Input data points to fit.

  • y (numpy.ndarray or pandas.DataFrame) – Input data points to fit.

  • z (numpy.ndarray or pandas.DataFrame) – Input data points to fit.

  • max – (int). Random select max datapoints. Used to limit the input size for performances.

  • seed – (int). The seed used to random selection. See (max)

get_kernel_ptr()[source]

Return a smart pointer to the current kernel used by codpy.

set_kernel_ptr()[source]

Set codpy with a kernel.

set_polynomial_order()[source]

Allow to set an integer, used for polynomial regression with codpy’s internal kernels.

Parameters:

order – (int). The order for polynomial regression : - 0 means regression on a constant (one regression) - 1 means constant and linear regression (one + \(D\) regression). - 2 means constant, linear regression and quadratic regression (one + \(D\) + \(D^2\) regression)..

set_regularization()[source]

Set a float value for Tykhonov regularization in kernel ridge inversion.

pipe_kernel_ptr()[source]
pipe_kernel_fun(regularization=1e-08)[source]
init(y=[], z=[], **kwargs)[source]
set_kernel(reg=1e-08, check_=True, extras={})[source]

An utility to instruct codpy to set a kernel. The list of available kernels is given by factories.get_map_factory_keys()

Parameters:
set_map(check_=True, kwargs={})[source]

An utility to set an internal codpy map for kernels. The list of available maps is given by factories.get_map_factory_keys()

Parameters:

strings

(str or list). A list of maps :

  • if str: instanciate and set to codpy the map.

  • if list: instanciate and set to codpy the first map, then ‘pipe’ (means compose) the others maps.

class codpy.core.map_setters[source]

Bases: object

A collection of classes / function to manipulate internal codpy maps. Internal codpy maps can be listed using factories.get_map_factory_keys()

class set(strings)[source]

Bases: object

__init__(strings)[source]
set_linear_map()[source]

Set a linear map for the kernel.

Args: - **kwargs: Arbitrary keyword arguments for the linear map configuration.

set_affine_map()[source]

Set an affine map for the kernel.

Args: - **kwargs: Arbitrary keyword arguments for the affine map configuration.

set_log_map()[source]

Set a logarithmic map for the kernel.

Args: - **kwargs: Arbitrary keyword arguments for the log map configuration.

set_exp_map()[source]

Set an exponential map for the kernel.

Args: - **kwargs: Arbitrary keyword arguments for the exponential map configuration.

set_scale_std_map()[source]

Set a standard scaling map for the kernel.

Args: - **kwargs: Arbitrary keyword arguments for the scale standard map configuration.

set_erf_map()[source]

Set an error function (ERF) map for the kernel.

Args: - **kwargs: Arbitrary keyword arguments for the ERF map configuration.

set_erfinv_map()[source]

Set an inverse error function (ERF) map for the kernel.

Args: - **kwargs: Arbitrary keyword arguments for the inverse ERF map configuration.

set_scale_factor_map()[source]

Set a scaling factor map for the kernel.

Args: - **kwargs: Arbitrary keyword arguments for the scale factor map configuration.

set_scale_factor_helper()[source]

Helper function to set a scaling factor map with specified bandwidth.

Args: - **kwargs: Arbitrary keyword arguments, including ‘bandwidth’ for the scale factor map configuration.

set_unitcube_map()[source]

Set a unit cube map for the kernel.

Args: - **kwargs: Arbitrary keyword arguments for the unit cube map configuration.

set_grid_map()[source]

Set a grid map for the kernel.

Args: - **kwargs: Arbitrary keyword arguments for the grid map configuration.

set_mean_distance_map()[source]

Set a mean distance map for the kernel.

Args: - **kwargs: Arbitrary keyword arguments for the mean distance map configuration.

set_min_distance_map()[source]

Set a minimum distance map for the kernel.

Args: - **kwargs: Arbitrary keyword arguments for the minimum distance map configuration.

set_standard_mean_map()[source]

Set a standard mean map pipeline for the kernel.

This function sets a mean distance map and then pipes it through the erf-inverse and unit cube maps.

Args: - **kwargs: Arbitrary keyword arguments for the standard mean map configuration.

set_standard_min_map()[source]

Set a standard minimum map pipeline for the kernel.

This function sets a minimum distance map and then pipes it through the erf-inverse and unit cube maps.

Args: - **kwargs: Arbitrary keyword arguments for the standard minimum map configuration.

set_unitcube_min_map()[source]

Set a unit cube minimum map pipeline for the kernel.

This function sets a minimum distance map and then pipes it through the unit cube map.

Args: - **kwargs: Arbitrary keyword arguments for the unit cube minimum map configuration.

set_unitcube_erfinv_map()[source]

Set a unit cube erf-inverse map pipeline for the kernel.

This function sets an erf-inverse map and then pipes it through the unit cube map.

Args: - **kwargs: Arbitrary keyword arguments for the unit cube erf-inverse map configuration.

set_unitcube_mean_map()[source]

Set a unit cube mean map pipeline for the kernel.

This function sets a mean distance map and then pipes it through the unit cube map.

Args: - **kwargs: Arbitrary keyword arguments for the unit cube mean map configuration.

map_helper(**kwargs)[source]

This function creates a partial function for a specified map setter with provided arguments.

Args: - map_setter (function): The map setter function to be used. - **kwargs: Arbitrary keyword arguments for the map setter function.

class codpy.core.kernel_setters[source]

Bases: object

kernel_helper(polynomial_order: int = 0, regularization: float = 1e-08, set_map=None)[source]
set_kernel(polynomial_order: int = 2, regularization: float = 1e-08, set_map=None)[source]

Set the kernel function with specified parameters.

This method configures the kernel function used in the calculations. It allows setting the type of kernel, its polynomial order, regularization factor, and an optional mapping function.

Args: - kernel_string (str): The name of the kernel function to use. - polynomial_order (int): The polynomial order for the kernel function. - regularization (float): The regularization parameter for the kernel. - set_map (callable, optional): An optional mapping function to apply.

The method configures the kernel and its associated parameters, preparing it for use in subsequent calculations.

set_linear_regressor_kernel(regularization: float = 1e-08, set_map=None)[source]

Set the linear regression kernel with specified parameters.

Args: - polynomial_order (int): The polynomial order for the kernel function. - regularization (float): The regularization parameter for the kernel. - set_map (callable, optional): An optional mapping function to apply.

set_absnormkernel(regularization: float = 1e-08, set_map=None)[source]

Set the absolute norm kernel with specified parameters.

Args: - polynomial_order (int): The polynomial order for the kernel function. - regularization (float): The regularization parameter for the kernel. - set_map (callable, optional): An optional mapping function to apply.

set_tensornorm_kernel(regularization: float = 1e-08, set_map=None)[source]

Set the tensor norm kernel with specified parameters.

Args: - polynomial_order (int): The polynomial order for the kernel function. - regularization (float): The regularization parameter for the kernel. - set_map (callable, optional): An optional mapping function to apply.

set_gaussian_kernel(regularization: float = 1e-08, set_map=None)[source]

Set the Gaussian kernel with specified parameters.

Args: - polynomial_order (int): The polynomial order for the kernel function. - regularization (float): The regularization parameter for the kernel. - set_map (callable, optional): An optional mapping function to apply.

set_matern_tensor_kernel(regularization: float = 1e-08, set_map=None)[source]

Set the Matérn tensor kernel with specified parameters.

Args: - polynomial_order (int): The polynomial order for the kernel function. - regularization (float): The regularization parameter for the kernel. - set_map (callable, optional): An optional mapping function to apply.

default_multiquadricnormkernel_map()

Set a standard mean map pipeline for the kernel.

This function sets a mean distance map and then pipes it through the erf-inverse and unit cube maps.

Args: - **kwargs: Arbitrary keyword arguments for the standard mean map configuration.

set_multiquadricnorm_kernel(regularization: float = 1e-08, set_map=functools.partial(<function map_setters.set_standard_mean_map>, distance='norm2'))[source]

Set the multi-quadric norm kernel with specified parameters.

Args: - polynomial_order (int): The polynomial order for the kernel function. - regularization (float): The regularization parameter for the kernel. - set_map (callable, optional): An optional mapping function defined as default_multiquadricnormkernel_map.

default_multiquadrictensorkernel_map()

Set a standard minimum map pipeline for the kernel.

This function sets a minimum distance map and then pipes it through the erf-inverse and unit cube maps.

Args: - **kwargs: Arbitrary keyword arguments for the standard minimum map configuration.

set_multiquadrictensor_kernel(regularization: float = 1e-08, set_map=functools.partial(<function map_setters.set_standard_min_map>, distance='normifty'))[source]

Set the multi-quadric tensor kernel with specified parameters.

Args: - polynomial_order (int): The polynomial order for the kernel function. - regularization (float): The regularization parameter for the kernel. - set_map (callable, optional): An optional mapping function defined as default_multiquadrictensorkernel_map.

default_sincardtensorkernel_map()

Set a minimum distance map for the kernel.

Args: - **kwargs: Arbitrary keyword arguments for the minimum distance map configuration.

set_sincardtensor_kernel(regularization: float = 1e-08, set_map=functools.partial(<function map_setters.set_min_distance_map>, distance='normifty'))[source]

Set the sinc cardinal tensor kernel with specified parameters.

Args: - polynomial_order (int): The polynomial order for the kernel function. - regularization (float): The regularization parameter for the kernel. - set_map (callable, optional): An optional mapping function defined as default_sincardtensorkernel_map.

default_sincardsquaretensorkernel_map()

Set a minimum distance map for the kernel.

Args: - **kwargs: Arbitrary keyword arguments for the minimum distance map configuration.

set_sincardsquaretensor_kernel(regularization: float = 0, set_map=functools.partial(<function map_setters.set_min_distance_map>, distance='normifty'))[source]

Set the sinc cardinal square tensor kernel with specified parameters.

Args: - polynomial_order (int): The polynomial order for the kernel function. - regularization (float): The regularization parameter for the kernel. - set_map (callable, optional): An optional mapping function defined as default_sincardsquaretensorkernel_map.

set_dotproduct_kernel(regularization: float = 1e-08, set_map=None)[source]

Set the dot product kernel with specified parameters.

Args: - polynomial_order (int): The polynomial order for the kernel function. - regularization (float): The regularization parameter for the kernel. - set_map (callable, optional): An optional mapping function to apply.

set_gaussianper_kernel(regularization: float = 1e-08, set_map=None)[source]

Set the Gaussian periodic kernel with specified parameters.

Args: - polynomial_order (int): The polynomial order for the kernel function. - regularization (float): The regularization parameter for the kernel. - set_map (callable, optional): An optional mapping function to apply.

set_matern_norm_kernel(regularization: float = 1e-08, set_map=<function map_setters.set_mean_distance_map>)[source]

Set the Matérn norm kernel with specified parameters.

Args: - polynomial_order (int): The polynomial order for the kernel function. - regularization (float): The regularization parameter for the kernel. - set_map (callable, optional): An optional mapping function defined as map_setters.set_mean_distance_map.

set_scalar_product_kernel(regularization: float = 1e-08, set_map=None)[source]

Set the scalar product kernel with specified parameters.

Args: - polynomial_order (int): The polynomial order for the kernel function. - regularization (float): The regularization parameter for the kernel. - set_map (callable, optional): An optional mapping function to apply.

codpy.core.kernel_setter(kernel, map, polynomial_order=0, regularization=1e-08, bandwidth=1.0)[source]

Set the kernel function with specified parameters using string identifiers.

Parameters:
  • kernel (str) – The name of the kernel function to use.

  • map (str) – The name of the mapping function to use.

  • polynomial_order (int) – The polynomial order for the kernel function.

  • regularization (float) – The regularization parameter for the kernel.

Returns:

The configured kernel function.