MATLAB: How to optimize machine-learning model exported from regression learner app

machine learningMATLAB

Thank you for visiting this question.
Now I've tried to optimize my machine-learning model exported from regression learner app.
This model has 27 inputs, and there is no certain numerical equation for result.
I googled keywords such as optimization of trained model, or optimization using GAMS, but I've failed to find proper items.
Please help me !

Best Answer

Hi Manhee,
After exporting the model from Regression Learner App, a structure variable is exported to workspace using it prediction on the test dataset can be done.
There are two possible ways to optimize:
  • Optimization can be done in MATLAB script after using Generate Function under Export. This will generate MATLAB script containing trainRegressionModel function as shown below:
% [trainedModel, validationRMSE] = trainRegressionModel(trainingData)
% Returns a trained regression model and its RMSE. This code recreates the
% model trained in Regression Learner app.
%



% Input:
% trainingData: A table containing the same predictor and response
% columns as those imported into the app.
%
% Output:
% trainedModel: A struct containing the trained regression model. The
% struct contains various fields with information about the trained
% model.
%
% For example, to retrain a regression model trained with the original data
% set T, enter:
% [trainedModel, validationRMSE] = trainRegressionModel(T)
%
% To make predictions with the returned 'trainedModel' on new data T2, use
% yfit = trainedModel.predictFcn(T2)
The trainRegressionModel function has fit function which can be modified to optimize the model. Refer to Bayesian Optimization Workflow documentation (section - Parameters Available for Fit Functions) for more information related to different kind of fit functions.