please help me modify my code so that i can fixt the below mentioned errors

1 visualización (últimos 30 días)
clear; clc; close all;
%% prepare dataset
filename = 'P1';
Spi = xlsread(filename,'B4:B769');
%% Normalization of data
N = size(Spi)
for i = 1 : size(Spi,1)
Spi_N(i) = ((Spi(i) - min(Spi))/(max(Spi) - min(Spi)));
end
X = [Spi_N']
%% 70:30 training and testing
rng default
rand_num = randperm(766);
x_train = X(rand_num(1:536),:);
x_test = X(rand_num(536:end),:);
%% best hyperparameters
rng default
Mdl = fitrsvm(x_train, 'KernelFunction', 'rbf', 'KernelScale','auto','Standardize',true,...
'OptimizeHyperparameters', 'auto', 'HyperparameterOptimizationOptions',struct('AcquisitionFunctionName',...
'expected-improvement-plus','ShowPlots',true));
%% Testing
x_predicted_test = predict(Mdl, x_test);
error_test = (x_test - x_predicted_test);
mean_absolute_error_test = mae(error_test)
root_mean_square_error_test = rms(error_test)
r_test = corrcoef(x_test,x_predicted_test)
%% Training
x_predicted_train = predict(Mdl, x_train);
error_train = (x_train - x_predicted_train);
mean_absolute_error_train = mae(error_train)
root_mean_square_error_train = rms(error_train)
r_train = corrcoef(x_train,x_predicted_train)
%% ALL data testing
x_predicted_all = predict(Mdl, X);
error_all = (X - x_predicted_all);
mean_absolute_error_all = mae(error_all)
root_mean_square_error_all = rms(error_all)
r_all = corrcoef(X ,x_predicted_all)
%%
save svm8.mat;
----------------------------------------------------------------------------- end of code -------------------------
errors:
Error using internal.stats.parseArgs (line 42)
Wrong number of arguments.
Error in classreg.learning.paramoptim.parseOptimizationArgs (line 10)
[OptimizeHyperparameters,HyperparameterOptimizationOptions,~,RemainingArgs] = internal.stats.parseArgs(...
Error in fitrsvm (line 277)
[IsOptimizing, RemainingArgs] = classreg.learning.paramoptim.parseOptimizationArgs(varargin);
Error in svm8original (line 20)
Mdl = fitrsvm(x_train, 'KernelFunction', 'rbf', 'KernelScale','auto','Standardize',true,...

Respuestas (1)

Aditya Patil
Aditya Patil el 29 de Mzo. de 2021
There are two issues in the code.
First, your normalization code creates a one column vector. You can replace the normalization code with,
X = normalize(Spi);
Second, you also need to pass the Y variable to the fitrsvm function. Y should have one columns, and same number of rows as X.

Categorías

Más información sobre Support Vector Machine Regression en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by