Creating Untrained Models
- 02:13
Creating, training, and evaluating liquidity models using Scikit-learn's Grid Search CV function, focusing on hyperparameter tuning and cross-validation to ensure model accuracy.
Downloads
No associated resources to download.
Glossary
Hyperparameter tuning Machine Learning PythonTranscript
You'll follow 4 steps to cross validate and score your liquidity models. First, you'll create untrained models for each model class. Second, you'll train each model and tune the hyperparameters. Third, you'll use the train models to make predictions based on the inputs from your testing data. And then finally, you'll compare the predictions against the actual target values from your testing data to score each model. To create untrained models. For each model class, you'll use psychic learns, gridsearchcv function. Check out the first line right here and follow along to import this function into your Jupyter Notebook. The format you see on the bottom line is how you can create your untrained model. So start by creating the name. In this case, we're calling it untrained lasso model and setting that equal to the function gridsearchcv, which then receives three arguments. First, go into your pipeline's dictionary and get the lasso item to give the gridsearchcv function, the lasso pipeline. For the second argument, we're gonna go into our hyperparameter grids dictionary and get the lasso item so that gridsearchcv knows which hyper parameters it's testing, using that lasso pipeline. And then finally, for the third argument, we're telling it how many folds of cross validation to perform. And in this case, we're doing 5 fold cross validation, which means it's performing the cross validation process 5 times. Once you execute this cell, the object untrained lasso model will contain first the lasso pipeline. Second, all of the hyperparameter configurations for lasso. And then third instructions to perform 5 fold cross validation. Once given the training data to tune the hyperparameters, make sure that you've copied this code in your Jupyter notebook before moving on.
In the next exercise, you're going to write a four loop to create untrained models for each model class. Remember, these are the pipelines and the hyperparameter grids that you previously made. You can see it by printing pipelines, keys, and hyperparameter grids keys. And notice that the keys that we created match, and that's gonna be important for the for loop that you're about to write in exercise 6.1.