Hyperparameter Grid Workout 1
- 02:21
How to create hyperparameter grids for Ridge, Lasso, and Elastic Net models in machine learning, focusing on the importance of matching hyperparameter names exactly as they are predefined in the Scikit-learn package.
Downloads
No associated resources to download.
Transcript
You're going to create hyper parameter grids for the ridge model and the elastic net model. First, create a hyper parameter grid, named ridge hyper parameters with one item. The key is going to be ridge, followed by two underscores and alpha. This must match exactly. Next, the value is going to be a list containing the objects 0.01, 0.05, 0.1, 0.5, 1, and 5.
When you're done with that, create another hyperparameter grid named enet hyperparameters with two items. For the first item, the key is elastic net, and then two underscores alpha. The value is a list containing 0.01, 0.05, 0.1, 0.5, 1, and 5. For the next item, the key is elastic net, double underscore L1, single underscore ratio. Make sure that it matches exactly, and the values are a list containing 0.1, 0.3, 0.5, 0.7, and 0.9.
You should have already created a hyperparameter grid for lasso like you see in the first cell right here. Next, we're going to create new dictionaries. The first one we're going to call ridge hyperparameters, and then open curly brace to start your dictionary, the first hyperparameter is ridge alpha, and make sure that this is two underscores. These hyper parameter names must match exactly because they're already written inside the psyche learn package. We can't customize it if we want it to work correctly. So those values are gonna be the values that you see right here. And then next we're going to create a hyperparameter dictionary for elastic net. Again, this must match exactly and it has two underscores in between elastic net and alpha and use the values that you see right here. Finally, we're going to add the elastic net L1 ratio, and you have two underscores between elastic net and L1 and one underscore between L1 and ratio. And when you create that item, the value should be a list containing the objects you see here.