Formula used
| Kernel | Formula | Typical use |
|---|---|---|
| Linear | K(x,y) = x·y | High-dimensional linear data |
| Polynomial | K(x,y) = (γx·y + r)ᵈ | Feature interactions |
| RBF | K(x,y) = exp(-γ||x-y||²) | Flexible nonlinear boundaries |
| Sigmoid | K(x,y) = tanh(γx·y + r) | Neural-style similarity |
| Laplacian | K(x,y) = exp(-γ||x-y||₁) | Robust distance decay |
| Cosine | K(x,y) = x·y/(||x||||y||) | Text and direction similarity |
| Chi-square | K(x,y) = exp(-γΣ((xi-yi)²/(xi+yi))) | Histograms and counts |
| Histogram | K(x,y) = Σmin(xi,yi) | Image histogram overlap |
| ANOVA | K(x,y) = Σexp(-σ(xi-yi)²)ᵈ | Structured nonlinear effects |
| Rational quadratic | K(x,y) = 1 - d²/(d²+c) | Multi-scale similarity |
How to use
- Select a calculation mode and kernel.
- Enter vectors or dataset rows.
- Choose parameters and preprocessing.
- Enable matrix processing when needed.
- Press Calculate kernel.
- Review values, charts, and matrix checks.
- Copy or export the final results.
Example data
| Task | Input | Suggested kernel | Parameters |
|---|---|---|---|
| Vector similarity | X: 1,2,3; Y: 2,1,4 | RBF | Gamma 0.5 |
| Text direction | Term-frequency vectors | Cosine | L2 normalization |
| Image histograms | Non-negative bins | Chi-square | Gamma 0.2 |
| Kernel PCA | Dataset rows | RBF | Centered matrix |
| Polynomial SVM | Standardized features | Polynomial | Degree 2 or 3 |
Kernel function guidance
A kernel measures similarity between samples. It can represent implicit feature mappings. This avoids constructing every transformed feature directly.
Gamma controls local influence in several kernels. Large gamma values create narrow similarity regions. Small values create smoother global relationships.
A valid Gram matrix should be symmetric. Positive semidefiniteness is commonly expected. Small negative eigenvalues can reflect numerical rounding.
Frequently asked questions
What is the kernel trick?
It computes inner products in transformed spaces. The transformation stays implicit. This reduces difficult feature construction.
Which kernel should I choose?
Start with linear for simple structure. Try RBF for nonlinear patterns. Compare validation performance before deciding.
What does gamma control?
Gamma controls how quickly similarity declines. Higher gamma creates local influence. Lower gamma creates broader influence.
Why standardize features?
Large-scale features can dominate distances. Standardization balances feature influence. It often improves parameter selection.
What is a Gram matrix?
It stores pairwise kernel values. Rows and columns represent observations. Many kernel methods use it directly.
What does PSD mean?
PSD means positive semidefinite. Valid kernels usually produce PSD matrices. Eigenvalues help test this condition.
Can cosine similarity be negative?
Yes, opposite directions produce negative similarity. Orthogonal vectors produce zero. Aligned vectors produce one.
Why add diagonal jitter?
Jitter can improve numerical stability. It slightly raises diagonal values. Use the smallest effective amount.
Is the custom expression safe?
The parser accepts limited arithmetic only. It rejects PHP code and unknown functions. This reduces execution risks substantially.