Each example in a dataset has features, the inputs the model looks at, and a label, the answer we want it to predict.
python · editable
Enroll in the course to run this code.
Train and test
A model that has seen an example can simply remember it. To know how it does on new data, we hide part of the dataset while training and only use it at the end. That hidden part is the test set.
python · editable
Enroll in the course to run this code.
We shuffle first so the split is not biased by the order the data was collected in, and fix the seed so the result is repeatable.