# Splitting Data with train_test_split

train_test_split shuffles the examples and holds a share back as test data (test_size=0.2 holds back a fifth, and 25% when no size is given), random_state fixes the shuffle so every run splits the same way, and the split comes before anything learns, so the test homes stay unseen.

![Cheat sheet: Splitting Data with train_test_split](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/69fa58da47e24b97a972e212e25846f1.webp)

- Category: Machine Learning
- Level: Journeyman
- Tags: ai, python, Random Seed, Test Data, train_test_split(), Training Data
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/ml-train-test-split-cheat-sheet
