Cross-Validation Workout
- 01:13
Practice creating and storing untrained models in a Jupiter notebook.
Downloads
No associated resources to download.
Glossary
Machine Learning Python untrained modelsTranscript
In your Jupyter Notebook, complete the following steps to create and store your untrained models. First, create an empty dictionary named models. Then for every key in pipelines dot keys, add a new item to models. The items key in models should be the same as the key in pipelines, and the items value should be the untrained model using 5fold cross validation. Finally, display all of the keys in models.
First, make sure that you imported the gridsearchcv function during the lesson. Then we will start by initializing this empty models dictionary. We'll create a for loop that says, for each key in the pipelines dot keys iterable, we want to create an item in the model. And the key for the item in the model is the same as the key in the pipeline, and the value's going to be equal to the gridsearchcv function, where the first argument is the pipeline for that model. The second argument is the hyper parameter for the model, and we're using fivefold cross validation. And here I've split this into separate lines, but it works adjust as well to have it all on the same line like this. It's just a formatting preference.