how to calculate kernel covariance function in Gaussian Process Regression?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have data X(x1,x2,x3) which is 24445x3 and y is also 24445 x 1.
I calculated kernel function matrix using this : https://kr.mathworks.com/matlabcentral/answers/251782-calculating-the-matrix-k-at-test-inputs-after-training-a-gaussian-process-with-fitrgp
the result is 24445 x 24445. is this size right?
and with this data, I want to plot like this image.
but when i plot with this data(24445x 24445), the error occured saying that out of memory
kfcn = regressionGP.Impl.Kernel.makeKernelAsFunctionOfXNXM(regressionGP.Impl.ThetaHat)
k= kfcn(x1(:,:),x1(:,:));
hm = heatmap(k);
plot(hm)
thanks.
0 commentaires
Réponses (1)
Kartik
le 23 Fév 2023
Hi,
The size of the kernel matrix you obtained is indeed 24445 x 24445, which is the correct size for a kernel matrix computed from 24445 data points.
Regarding the memory error when trying to plot the heatmap, the issue is likely due to the large size of the kernel matrix, which requires a lot of memory to store and plot. One way to address this is to plot only a subset of the data, such as a random sample of, say, 1000 data points. You can do this by selecting a random subset of rows and columns from the kernel matrix, in the following way:
% Generate a random subset of indices
idx = randperm(size(k, 1), 1000);
% Plot the heatmap using only the selected subset
hm = heatmap(k(idx, idx));
This code selects a random subset of 1000 rows and columns from the kernel matrix and plots the corresponding submatrix. Note that the resulting plot will only show a portion of the overall data, but it should still provide a good visual representation of the overall structure of the kernel matrix.
Alternatively, you can also try to reduce the size of the kernel matrix by using a different kernel function or by applying dimensionality reduction techniques such as PCA or t-SNE to the input data before computing the kernel matrix. This can help to reduce the computational and memory requirements of working with large datasets.
Refer to the following MathWorks documentation to know more about the same.
0 commentaires
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!