Machine LearningLesson 80Free preview
Train/Test
This lesson is part of Python · All levels
Summary
The data is generally divided into training data to train models and test data to evaluate them. sklearn.model_selection.train_test_split performs this division randomly with a certain proportion, e.g. 80 percent of training and 20 percent of testing. The random_state argument makes the division reproducible in every experiment. Valid evaluation is only possible if the model is evaluated on data that was never used during training.
Key points
- The data is divided into train sets and test sets
- Test_size determines the proportion of test data, for example 0.2 to 20 percent
- Random_state makes the random distribution consistent
- The model should not be evaluated on the data used to train it.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.