필터 지우기
필터 지우기

How to use Kernel Ridge Regression Function in Matlab - fitrkernel

조회 수: 13 (최근 30일)
Telema Harry
Telema Harry 2023년 10월 4일
답변: Anjaneyulu Bairi 2023년 10월 11일
I am trying to perform regression using kernel ridge regression in Matlab. Is there a dedicated function for Kernel Ridge Regression in Matlab?
I used the fitrkernel function, but the result is not correct. Am I doing something wrong?
Secondly, how can I specify the kernel to use.
N = 100;
data_x = linspace(0,20,N);
data_x = data_x';
data_y = sin(data_x);
[Mdl, FitInfo] = kernel_ridge_regression1(data_x, data_y);
x_test = linspace(0,15,75);
x_test = x_test';
actual_y = sin(x_test) ;
y_predict = predict(Mdl,x_test); % I used same data to test the results
figure(2)
plot(x_test,actual_y, 'o','lineWidth',2);
hold on
plot(x_test,y_predict, 'r','lineWidth',2);
legend("Original y", "Predicted y", 'interpreter','latex')
xlabel ('$x$','fontsize',18,'interpreter','latex')
ylabel('$y$','fontsize',18,'interpreter','latex')
%% FUNCTION
function [Mdl, FitInfo] = kernel_ridge_regression1(data_x_train, data_y_train)
data_x_train_b = zscore(data_x_train); % Standardize the data
[Mdl,FitInfo] = fitrkernel(data_x_train_b ,data_y_train);
end

답변 (1개)

Anjaneyulu Bairi
Anjaneyulu Bairi 2023년 10월 11일
I Understand that you are trying to perform regression using kernel ridge regression. Try to explore the below link and download the files which has example and explanation of Kernel Ridge Regression and please note that it is a third-party support package and not provided by MathWorks.
I hope it helps to resolve your query.

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by