SVEKER.kernels.RBFKernel

class SVEKER.kernels.RBFKernel(no_player_value=0.0, gamma=1.0)

Implements the RBF Kernel

\(K(I, D) = \exp{}\left\{ -\gamma D\right\}\)

__init__(no_player_value=0.0, gamma=1.0) None

Initializes the RBF Kernel.

Parameters:

gamma (float) – Parameter \(\gamma\) for the RBF kernel.

delta_nu_fminus(n_i: int, n_d: int) float

Calculates the change in the RBF Kernel upon adding a feature to the symmetric difference.

\[\begin{split}\Delta\nu_{f^-} (N_i, N_d) = \begin{cases} \exp{}\left\{-\gamma (N_d + 1)\right\} - \nu(\varnothing) & \text{if } N_i = 0 \text{ and } N_d = 0 \\ \exp{}\left\{-\gamma (N_d + 1)\right\} - \exp{}\left\{-\gamma N_d\right\} & \text{else} \end{cases}\end{split}\]
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

delta_nu_fplus(n_i: int, n_d: int) float

Calculates the change in the RBF Kernel upon adding a feature to the intersection.

\[\begin{split}\Delta\nu_{f^+} (N_i, N_d) = \begin{cases} 1 - \nu(\varnothing) & \text{if } N_i = 0 \text{ and } N_d = 0 \\ 0 & \text{else} \end{cases}\end{split}\]
Parameters:
  • n_i (int) – Number of elements in the intersection, \(N_i\)

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

Returns:

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

Return type:

float

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

Simplified summation for the Shapley value calculation for adding a feature to the symmetric difference. Only valid for RBF Kernel.

\[\begin{split}\begin{split} \phi_{f^-} (I, D) =& \frac{\exp{}\left\{-\gamma\right\} - \nu(\varnothing)}{I+D} \\ & + \left( \exp{}\left\{ -\gamma\right\} -1\right) \sum_{N_i=1}^I \binom{I}{N_i} \, m_\mathrm{coeff}(N_i, 0, I, D) \\ & + \sum_{N_i = 0}^{I} \sum_{N_d = 1}^{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) \end{split}\end{split}\]
Parameters:
  • i (int) – Size of intersection, \(I\)

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

Returns:

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

Return type:

float

phi_fplus(i: int, d: int) float

Simplified summation for the Shapley value calculation for adding a feature to the intersection. Only valid for RBF Kernel.

\(\phi_{f^+} (I, D) = \frac{1-\nu(\varnothing)}{I + D}\)

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