Is it possible to construct gaussian processes custom kernels with built in functions?

1 次查看(过去 30 天)
I understand the way to construct custom kernels for gaussian processes, e.g.
kfcn = @(XN,XM,theta) exp(theta(1))^2*exp(-pdist2(XN,XM).^2/(2*exp(theta(2))^2))
I am wondering if it is possible to construct kernels from built in function names, e.g.
kfcn = 'exponential' + 'squaredexponential';
If not, does it mean we have to do it from scatch?
Any suggesion would be appreciated.

采纳的回答

Walter Roberson
Walter Roberson 2023-5-3
You can use str2func to convert a function name or text expression into a function handle.
kfcns = {'exponential','squaredexponential'};
KFCN = str2func("@(x) " + strjoin(string(kfcns(:)) + "(x)", " + "))
KFCN = function_handle with value:
@(x)exponential(x)+squaredexponential(x)
  5 个评论
Walter Roberson
Walter Roberson 2023-5-4
The actual functions called are several layers down and obviouslyly not intended to be directly invoked by the user. For example toolbox/stats/classreg/+classreg/+learning/+coder/+gputils/squaredExponentialKfun.m
mono
mono 2023-5-4
python scikit learn actually supports it. I feel it is quite convince as it is quite time consusing if constructing all the custom kernels from the scatch.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by