Skip to content

cosine_similarity_interdependence

Bases: numerical_kernel_based_interdependence

A kernel-based interdependence class using a cosine similarity kernel.

Notes

Cosine Similarity based Kernel:

\[
    \begin{equation}
    \text{kernel}(\mathbf{x}, \mathbf{y}) = \frac{\left\langle \mathbf{x}, \mathbf{y} \right \rangle}{\left\|\mathbf{x}\right\| \cdot \left\| \mathbf{y} \right\|}.
    \end{equation}
\]

Attributes:

Name Type Description
kernel Callable

The cosine similarity kernel function.

Methods:

Name Description
__init__

Initializes the cosine similarity interdependence function.

Source code in tinybig/interdependence/numerical_kernel_interdependence.py
class cosine_similarity_interdependence(numerical_kernel_based_interdependence):
    r"""
        A kernel-based interdependence class using a cosine similarity kernel.

        Notes
        ----------
        __Cosine Similarity based Kernel:__

        $$
            \begin{equation}
            \text{kernel}(\mathbf{x}, \mathbf{y}) = \frac{\left\langle \mathbf{x}, \mathbf{y} \right \rangle}{\left\|\mathbf{x}\right\| \cdot \left\| \mathbf{y} \right\|}.
            \end{equation}
        $$

        Attributes
        ----------
        kernel : Callable
            The cosine similarity kernel function.

        Methods
        -------
        __init__(...)
            Initializes the cosine similarity interdependence function.
    """
    def __init__(self, name: str = 'cosine_similarity_interdependence', *args, **kwargs):
        """
            Initializes the cosine similarity interdependence function.

            Parameters
            ----------
            name : str, optional
                Name of the interdependence function. Defaults to 'cosine_similarity_interdependence'.
            *args : tuple
                Additional positional arguments for the parent class.
            **kwargs : dict
                Additional keyword arguments for the parent class.
        """
        super().__init__(kernel=cosine_similarity_kernel, name=name, *args, **kwargs)

__init__(name='cosine_similarity_interdependence', *args, **kwargs)

Initializes the cosine similarity interdependence function.

Parameters:

Name Type Description Default
name str

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

'cosine_similarity_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, name: str = 'cosine_similarity_interdependence', *args, **kwargs):
    """
        Initializes the cosine similarity interdependence function.

        Parameters
        ----------
        name : str, optional
            Name of the interdependence function. Defaults to 'cosine_similarity_interdependence'.
        *args : tuple
            Additional positional arguments for the parent class.
        **kwargs : dict
            Additional keyword arguments for the parent class.
    """
    super().__init__(kernel=cosine_similarity_kernel, name=name, *args, **kwargs)