Hyperparameter optimization fitrnet not working

Hi,
I'm trying to optimize the hyperparameters of a NN regression but I get an error regarding the inputs i give to the function fitrnet. I can't understand why since if I don't use ''OptimizeHyperparameters" but I specify the parameters my self the code works just fine.
%% training Neural Network regression
clear
clc
close all
load trainingSetReduced.mat
test = struct2table(test);
predictorNames = {'v_i', 'E_tip', 'rho_tip', 'v_tip', 'Y_tip', 'Radius', 'E_plate', 'rho_plate', 'v_plate', 'Y_plate', 'Insulator','BC','anvil'};
predictors = test(:, predictorNames);
responseNames = {'F1','F2','F3','F4','F5','F6','F7','F8','F9','F10','F11','F12','F13','F14','F15','F16','F17','F18','F19','F20'};
response = test(:,responseNames);
X = table2array(predictors);
Y = table2array(response);
% Train the neural network
regressionNeuralNetwork = fitrnet(...
X, ...
Y, ...
'OptimizeHyperparameters', 'all', ...
'HyperparameterOptimizationOptions', struct( ...
'Optimizer', 'bayesopt', ...
'AcquisitionFunctionName','expected-improvement-plus', ...
'UseParallel', true, ...
'ShowPlots', true, ...
'Verbose', 1, ...
'MaxObjectiveEvaluations', 30));
Error using mlearnlib.internal.utils.ClassLabel (line 26)
You must pass class labels as a vector.

Error in classreg.learning.internal.ClassLabel

Error in classreg.learning.paramoptim.BayesoptInfo>numClasses (line 299)
N = numel(levels(classreg.learning.internal.ClassLabel(Y)));

Error in classreg.learning.paramoptim.BayesoptInfo/computeInMemoryDatasetStats (line 276)
this.NumClasses = numClasses(Response, ClassNamesPassed);

Error in classreg.learning.paramoptim.BayesoptInfo (line 243)
this = computeInMemoryDatasetStats(this, Predictors, Response, FitFunctionArgs, ObservationsInCols, IsRegression);

Error in classreg.learning.paramoptim.BayesoptInfoRNeuralNetwork (line 21)
this@classreg.learning.paramoptim.BayesoptInfo(Predictors, Response, FitFunctionArgs, false, false);

Error in classreg.learning.paramoptim.BayesoptInfo.makeBayesoptInfo (line 176)
Obj = ConstructorFcn(Predictors, Response, FitFunctionArgs);

Error in classreg.learning.paramoptim.fitoptimizing (line 30)
BOInfo = classreg.learning.paramoptim.BayesoptInfo.makeBayesoptInfo(FitFunctionName, Predictors, Response, FitFunctionArgs);

Error in fitrnet (line 148)
[this, varargout{1:nargout-1}] = classreg.learning.paramoptim.fitoptimizing("fitrnet",X,Y,varargin{:});
Does anybofy have some suggestions on how to solve the problem?
Thank you in advance

 採用された回答

the cyclist
the cyclist 2025 年 4 月 13 日

0 投票

"You can use an array ResponseVarName to specify multiple response variables. (since R2024b)"
but also
"Hyperparameter optimization options are not supported for multiresponse regression."

1 件のコメント

Riccardo
Riccardo 2025 年 4 月 13 日

Thanks you! I completely missed that

サインインしてコメントする。

その他の回答 (0 件)

製品

リリース

R2024b

質問済み:

2025 年 4 月 13 日

コメント済み:

2025 年 4 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by