Skip to content

custom_hybrid_kernel_interdependence

Bases: numerical_kernel_based_interdependence

A kernel-based interdependence class using a custom hybrid kernel.

This class combines multiple kernel functions into a single hybrid kernel.

Notes

Custom Hybrid Kernel:

$$ \begin{equation} \text{kernel}(\mathbf{x}, \mathbf{y} | \alpha, \beta) = \alpha k_1(\mathbf{x}, \mathbf{y}) + \beta k_2(\mathbf{x}, \mathbf{y}), \end{equation} $$ where \(k_1\) and \(k_2\) are custom designed kernel, and \(\alpha, \beta\) are the weights.

Attributes:

Name Type Description
kernel Callable

The hybrid kernel function combining multiple kernels.

weights (List[float], optional)

Weights applied to each kernel function.

Methods:

Name Description
__init__

Initializes the custom hybrid kernel interdependence function.

Source code in tinybig/interdependence/numerical_kernel_interdependence.py
class custom_hybrid_kernel_interdependence(numerical_kernel_based_interdependence):
    r"""
        A kernel-based interdependence class using a custom hybrid kernel.

        This class combines multiple kernel functions into a single hybrid kernel.

        Notes
        ----------
        __Custom Hybrid Kernel:__

        $$
            \begin{equation}
            \text{kernel}(\mathbf{x}, \mathbf{y} | \alpha, \beta) = \alpha k_1(\mathbf{x}, \mathbf{y}) + \beta k_2(\mathbf{x}, \mathbf{y}),
            \end{equation}
        $$
        where $k_1$ and $k_2$ are custom designed kernel, and $\alpha, \beta$ are the weights.

        Attributes
        ----------
        kernel : Callable
            The hybrid kernel function combining multiple kernels.
        weights : List[float], optional
            Weights applied to each kernel function.

        Methods
        -------
        __init__(...)
            Initializes the custom hybrid kernel interdependence function.
    """
    def __init__(self, kernels: List[Callable[[np.matrix], np.matrix]], weights: List[float] = None, name: str = 'custom_hybrid_kernel_interdependence', *args, **kwargs):
        """
            Initializes the custom hybrid kernel interdependence function.

            Parameters
            ----------
            kernels : List[Callable[[np.matrix], np.matrix]]
                List of kernel functions to combine.
            weights : List[float], optional
                Weights applied to each kernel function. Defaults to None, indicating equal weights.
            name : str, optional
                Name of the interdependence function. Defaults to 'custom_hybrid_kernel_interdependence'.
            *args : tuple
                Additional positional arguments for the parent class.
            **kwargs : dict
                Additional keyword arguments for the parent class.
        """
        custom_hybrid_kernel_func = functools.partial(custom_hybrid_kernel, kernels=kernels, weights=weights)
        super().__init__(kernel=custom_hybrid_kernel_func, name=name, *args, **kwargs)

__init__(kernels, weights=None, name='custom_hybrid_kernel_interdependence', *args, **kwargs)

Initializes the custom hybrid kernel interdependence function.

Parameters:

Name Type Description Default
kernels List[Callable[[matrix], matrix]]

List of kernel functions to combine.

required
weights List[float]

Weights applied to each kernel function. Defaults to None, indicating equal weights.

None
name str

Name of the interdependence function. Defaults to 'custom_hybrid_kernel_interdependence'.

'custom_hybrid_kernel_interdependence'
*args tuple

Additional positional arguments for the parent class.

()
**kwargs dict

Additional keyword arguments for the parent class.

{}
Source code in tinybig/interdependence/numerical_kernel_interdependence.py
def __init__(self, kernels: List[Callable[[np.matrix], np.matrix]], weights: List[float] = None, name: str = 'custom_hybrid_kernel_interdependence', *args, **kwargs):
    """
        Initializes the custom hybrid kernel interdependence function.

        Parameters
        ----------
        kernels : List[Callable[[np.matrix], np.matrix]]
            List of kernel functions to combine.
        weights : List[float], optional
            Weights applied to each kernel function. Defaults to None, indicating equal weights.
        name : str, optional
            Name of the interdependence function. Defaults to 'custom_hybrid_kernel_interdependence'.
        *args : tuple
            Additional positional arguments for the parent class.
        **kwargs : dict
            Additional keyword arguments for the parent class.
    """
    custom_hybrid_kernel_func = functools.partial(custom_hybrid_kernel, kernels=kernels, weights=weights)
    super().__init__(kernel=custom_hybrid_kernel_func, name=name, *args, **kwargs)