SVEKER.kernels
.SigmoidKernel¶
- class SVEKER.kernels.SigmoidKernel(no_player_value=0.0, gamma=1.0, coef0=0.0)¶
Implements the Sigmoid kernel
\(K(I, D) = \tanh(\gamma I + r)\)
- __init__(no_player_value=0.0, gamma=1.0, coef0=0.0) None ¶
Initializes the Sigmoid Kernel.
- Parameters:
gamma (float) – Parameter \(\gamma\) for the Sigmoid kernel.
coef0 (float) – Parameter \(r\) for the Sigmoid kernel.
- delta_nu_fminus(n_i: int, n_d: int) float ¶
Calculates the change in the Sigmoid kernel upon adding a feature to the symmetric difference.
\[\begin{split}\Delta\nu_{f^-} (N_i, N_d) = \begin{cases} \tanh{}(r) - \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 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 Sigmoid kernel upon adding a feature to the intersection.
\[\begin{split}\Delta\nu_{f^+} (N_i, N_d) = \begin{cases} \tanh{}(\gamma (N_i + 1) + r) - \nu(\varnothing)& \text{if } N_i = 0 \text{ and } N_d = 0 \\ \tanh{}(\gamma (N_i + 1) + r) - \tanh{}(\gamma N_i + r) & \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 Sigmoid kernel.
\(\phi_{f^-} (I, D) = \frac{\tanh{}(r) - \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 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 Sigmoid kernel.
\[\begin{split}\begin{split} \phi_{f^+} (I, D) = & \frac{\tanh{}(\gamma + r) - \nu(\varnothing)}{I + D} \\ & + \Delta\nu_{f^+}(0, 1) \sum_{N_d=1}^D \binom{D}{N_d} \, m_\mathrm{coeff}(0, N_d, I, D) \\ & + \sum_{N_i = 1}^{I-1} \Delta\nu_{f^+}(N_i, 0) \sum_{N_d = 0}^{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 intersection, \(\phi_{f^+}\)
- Return type:
float