Why Matlab SVR is not working for exponential data and works well with data that fluctuates?

2 views (last 30 days)
I am doing some test with SVR functions in Matlab. One with a set of data with fluctuations and another set as a smooth exponential data. With the 1st, SVR is able to perform good regressions but with the exponential data is not even getting the same trend. Why? How to make same good regression for the smooth-exponential data?
Code and results for the data with fluctuations
%% SVR TEST DATA WITH FLUCTUATUATIONS
clear all
load carsmall
rng 'default' % For reproducibility
index=1:100;
index=index';
X = [Horsepower(1:90,1),Weight(1:90,1)];
Y = MPG(1:90,1);
Mdl = fitrsvm(X,Y)
%% Regression test
% Using the regression model to get last 10% of Horsepower
YFit = predict(Mdl,[Horsepower,Weight]);
%%
plot(MPG,'LineWidth',1);
hold on
plot(index(90:end),YFit(90:end),'LineWidth',2);
plot(index(1:90),YFit(1:90),'LineWidth',2);
legend('Real data','Unseen-data regression','Seen-data regression')
set(gca,'fontsize',15);
grid on;
grid minor;
xlabel('Index');
ylabel('Miles Per Gallon (MPG)');
Regression results of test data with fluctuations
Code and results for the data with NO-fluctuations
%% SVR TEST WITH EXPONENTIAL DATA
clear all
data=xlsread('test data.xlsx');
rng 'default' % For reproducibility
index=1:42;%
index=index';
X = [data(1:35,2),data(1:35,3)];
Y = data(1:35,1);
Mdl = fitrsvm(X,Y)
%% Regression test
% Using the regression model to get last 10% of Horsepower
YFit = predict(Mdl,[data(:,2),data(:,3)]);
%%
plot(data(:,1),'LineWidth',1);
hold on
plot(index(35:end),YFit(35:end),'LineWidth',2);
plot(index(1:35),YFit(1:35),'LineWidth',2);
legend('Real data','Unseen-data regression','Seen-data regression')
set(gca,'fontsize',15);
grid on;
grid minor;
xlabel('Index');
ylabel('exponential data');
Regression results of test data with NO-fluctuations

Answers (1)

Aditya Patil
Aditya Patil on 14 Jul 2021
SVR uses a linear kernel by default, which might not be appropriate for exponential data. You might want to try the gaussian kernel instead. See KernelFunction argument for more details.
As per my understanding, the validation data you are using is outside the domain of the training data. Extrapolating results outside the domain of the training data might give unreliable results, as there is no way to be confident about the accuracy of the model outside the domain during training.

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!