# Kernel functions

For a given kernel and support vectors we compute the `soft_score` that computes the overall `score` of a point `X` by summing the `kernel_scores` of the point `X` with each support vector `Y`.

`Assignment.``soft_score`(X, Y, K, **kwargs)

  Compute the soft score by computing the kernel function between each point and each support_vector. The scores are then added to create a soft score. Note that this function is not weighted, in reality weights are added to adjust the importance of each support vector.

  Parameters

    - X (np.array of shape=(n_samples, n_features)) – Points for which to compute the soft score.

    - Y (np.array of shape=(n_samples, n_features)) – Support vectors used to compute the score.

    - K (func) – Kernel function to compute each individual score.

    - **kwargs (optional) – Optional arguments for the kernel.

  Returns

    result – Soft score for each point in X.

  Return type

    np.array of shape=(n_samples,)

## Plotting

To show how this works, we plot the kernel score of randomly generated `support_vectors` for all combinations of parameters `sigmas` and `thresholds` using the following methods:

`Assignment.``plot_kernels`(K, sigmas=[None], thresholds=[None])

  Plot an example of randomly generated kernels.

  Parameters

    - K (func) – Kernel function to compute each individual score.

    - sigmas (list, default=[None]) – List of different values of sigma to plot.

    - thresholds (list, default=[None]) – List of different thresholds to plot.

`Assignment.``_plot_kernel_`(ax, support_vectors, K, threshold=2, **kwargs)

  Function to plot scores and decision boundary for given support vectors.

  Parameters

    - support_vectors (np.array of shape=(n_vectors, n_features)) – Support vectors for which to plot the soft score.

    - K (func) – Kernel function to compute the soft scores.

    - threshold (float, default=2) – Decision threshold. All scores higher than this threshold will be inside the model. All scores lower than this threshold will are anomalous.

    - **kwargs (optional) – Optional arguments to give to the kernel function K.