StringKernel<T>
Models & Types · AiDotNet.Kernels
Implements various string kernels for comparing text/sequence data in Gaussian Processes.
For Beginners
String kernels allow Gaussian Processes to work directly with text or sequence data without needing to convert them to fixed-length feature vectors.
The key insight: We can define a kernel (similarity measure) between strings that captures meaningful notions of similarity:
- Spectrum kernel: Counts shared substrings
- Subsequence kernel: Counts shared (possibly non-contiguous) subsequences
- Edit distance kernel: Based on how many edits to transform one string to another
Applications:
- Text classification (spam detection, sentiment analysis)
- Bioinformatics (DNA/protein sequence comparison)
- Natural language processing
- Any domain with sequential/string data
How It Works
Note: This class does NOT implement IKernelFunction
Constructors
| Constructor | Summary |
|---|---|
StringKernel(KernelType<T> kernelType, int substringLength, double lambda, double scale) |
Initializes a new string kernel. |
Properties
| Property | Summary |
|---|---|
KernelType<T> Type { get; } |
Gets the kernel type. |
Methods
| Method | Summary |
|---|---|
Matrix<T> ComputeKernelMatrix(string[] strings) |
Creates a kernel matrix for a collection of strings. |
T Calculate(string s1, string s2) |
Calculates the string kernel value between two strings. |