How to use Kernel Ridge Regression Function in Matlab - fitrkernel
조회 수: 6 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!