How to regularize a machine learning algorithm or a function with respect to some data points that I have chosen on my own

3 visualizaciones (últimos 30 días)
I have a set of points that I use as a training set on which then a regression will be built, at this point I want to regularize the regression with respect to points that I choose. in the 1D case the idea is to fit a line on a few points, then add more points and correct the slope of the line( lasso algorithm), but I have no idea how to do that because in matlab I can't find this option as I only have the cross validation option, instead I want to choose my validation set on which to regularize the regression.

Respuestas (1)

ag
ag el 12 de Sept. de 2023
Hi Luca,
I understand that you need to use specific data points of your choice as the validation set for your regression model.
There are multiple ways to achieve this, some of them are
  • You can split your dataset into training’, validation, and testing sets according to your requirements before feeding it to the model.
The code snippet below demonstrates how to split a dataset into 70% for training, 15% for validation, and 15% for testing:
[r,c] = size(dataset) ;
split1 = 0.70 ; split2 = 0.85 ; %split percentages
idx = randperm(r) ; %to shuffle the rows
m = round(split1*r) ; n = round(split2*r) ;
Training = dataset(idx(1:m),:) ;
Validation = dataset(idx(m+1:n),:) ;
Testing = dataset(idx(n+1:end),:) ;
  • You can use the ‘cvpartition’ MATLAB function.
  • You can utilize the Set aside a test data set feature in the Regression Learner App.
For more details, please refer the following MATLAB documentation
  1. https://www.mathworks.com/help/stats/cvpartition.html
  2. https://www.mathworks.com/help/stats/train-regression-model-using-hyperparameter-optimization-in-regression-learner-app.html
Hope this helps! 
Best Regards, Aryan Gupta 

Community Treasure Hunt

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

Start Hunting!

Translated by