SVEKER.kernels.BaseKernel

class SVEKER.kernels.BaseKernel(no_player_value)

Base Class for different kernels to be used.

Defines the necessary functions for the different kernels to be used.

__init__(no_player_value) None

Initializes the Base Kernel.

Parameters:

no_player_value – Kernel value associated to the empty coalition \(\nu(\varnothing)\)

abstract delta_nu_fminus(n_i: int, n_d: int) float

Calculates the change in the kernel upon addition of a feature to the symmetric difference, \(\Delta\nu_{f^-}\). Kernel-specific, needs to be implemented for the specific kernel.

Parameters:
  • n_i (int) – Number of elements in the intersection, \(N_i\)

  • n_d (int) – Number of elemtnes in the symmetric difference, \(N_d\)

Returns:

Change in kernel, \(\Delta\nu_{f^-}\)

Return type:

float

abstract delta_nu_fplus(n_i: int, n_d: int) float

Calculates the change in the kernel upon addition of a feature to the intersection, \(\Delta\nu_{f^+}\). Kernel-specific, needs to be implemented for the specific kernel.

Parameters:
  • n_i (int) – Number of elements in the intersection, \(N_i\)

  • n_d (int) – Number of elemtnes in the symmetric difference, \(N_d\)

Returns:

Change in kernel, \(\Delta\nu_{f^+}\)

Return type:

float

abstract get_kernel_function() Callable

Returns the Kernel function to be used with sklearn.SVC or sklearn.SVR. See kernel = 'precomputed' in the sklearn documentaion for details.

phi_fminus(i: int, d: int) float

Naïve implementation of Shapley value calculation for adding a feature to the symmetric difference.

\(\phi_{f^-} (I, D) = \sum_{N_i = 0}^{I} \sum_{N_d = 0}^{D-1} \Delta\nu_{f^-}(N_i, N_d) \, C_{f^-} (N_i, N_d, I, D) \, m_\mathrm{coeff}(N_i, N_d, I, D)\)

This summation is valid for all kernels but it can be simplified using the properties of the \(\Delta\nu_{f^-}(N_i, N_d)\) term.

Parameters:
  • i (int) – Size of intersection, \(I\)

  • d (int) – Size of the symmetric difference, \(D\)

Returns:

Shapley value for adding a feature to the intersection, \(\phi_{f^+}\)

Return type:

float

phi_fplus(i: int, d: int) float

Naïve implementation of Shapley value calculation for adding a feature to the intersection.

\(\phi_{f^+} (I, D) = \sum_{N_i = 0}^{I-1} \sum_{N_d = 0}^{D} \Delta\nu_{f^+}(N_i, N_d) \, C_{f^+} (N_i, N_d, I, D) \, m_\mathrm{coeff}(N_i, N_d, I, D)\)

This summation is valid for all kernels but it can be simplified using the properties of the \(\Delta\nu_{f^+}(N_i, N_d)\) term.

Parameters:
  • i (int) – Size of intersection, \(I\)

  • d (int) – Size of the symmetric difference, \(D\)

Returns:

Shapley value for adding a feature to the intersection, \(\phi_{f^+}\)

Return type:

float