MATLAB Answers

How do I get ridge regression tuning parameters from fitrtree and crossval?

11 views (last 30 days)
Jacob Yeung
Jacob Yeung on 5 Apr 2020
Answered: Asvin Kumar on 13 Apr 2020
I was wondering if I could use fitrtree to create a regression tree to then run crossval on to find the tuning parameters to then use in the Matlab ridge function.

Answers (1)

Asvin Kumar
Asvin Kumar on 13 Apr 2020
crossval finds the k-fold cross validation loss of a given model with respect to a given dataset. I don’t see how you can use fitrtree along with that to find the optimal ridge parameter ‘k’ for ridge. It is a model that you’re seeking to find in the first place.
Have a look at the methods mentioned on this page: They describe the many options available to optimize the hyperparameter for a wide variety of problems, including ridge regression.
fitrlinear seems like it will meet your requirements.
Here’s an example at if you want to test the performance of your model over a range of possible choices for the ridge parameter (‘Lambda’ Regularization Term Strength).
On the other hand, you can have the function optimize for the ridge parameter. Have a look at the example at This might be best suited for you. Set the name-value pair OptimizeHyperparameters’ to {‘Lambda’}.

Community Treasure Hunt

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

Start Hunting!