IndexKernel<T>
Models & Types · AiDotNet.Kernels
Index kernel for multi-task/multi-output Gaussian Processes.
Implements: IKernelFunction<T>
For Beginners
The IndexKernel enables GPs to model multiple related tasks or outputs simultaneously, sharing information between them.
In multi-task learning, you have multiple related prediction tasks. For example:
- Predicting exam scores for multiple subjects (math, science, english)
- Forecasting sales for multiple products
- Estimating properties of multiple chemical compounds
The IndexKernel models the correlation between tasks using a covariance matrix: k_task(t, t’) = B[t, t’]
Where B is a positive semi-definite “task covariance matrix” that captures:
- B[t, t]: The variance of task t
- B[t, t’]: The covariance between tasks t and t’
When combined with an input kernel (e.g., RBF), the full multi-task kernel is: k((x, t), (x’, t’)) = k_input(x, x’) × k_task(t, t’) = k_input(x, x’) × B[t, t’]
This allows the GP to:
- Share information between similar tasks
- Leverage data from data-rich tasks to help data-poor tasks
- Learn task relationships from data
How It Works
Usage patterns:
- Initialize with a task covariance matrix (if known)
- Initialize randomly and optimize the task covariance
- Use with ProductKernel to combine with input kernel
Constructors
| Constructor | Summary |
|---|---|
IndexKernel(double[] taskCovariance) |
Initializes an IndexKernel with a specified task covariance matrix. |
IndexKernel(int numTasks, int? rank, double variance, int? seed) |
Initializes an IndexKernel with specified number of tasks using random initialization. |
Properties
| Property | Summary |
|---|---|
int NumTasks { get; } |
Gets the number of tasks. |
Methods
| Method | Summary |
|---|---|
IndexKernel<T> Independent(int numTasks, double variance) |
Creates an IndexKernel with identity task covariance (independent tasks). |
IndexKernel<T> UniformCorrelation(int numTasks, double correlation, double variance) |
Creates an IndexKernel with uniform task correlation. |
T Calculate(Vector<T> x1, Vector<T> x2) |
Calculates the task kernel value between two task indices. |
double CalculateForTasks(int task1, int task2) |
Gets the task covariance for explicit task indices. |
double GetTaskCorrelation(int task1, int task2) |
Gets the correlation between two tasks. |
double[] GetTaskCovariance() |
Gets a copy of the task covariance matrix. |