# GroupShuffleSplit

*noun*

say it: **“GROOP SHUF-ul SPLIT”** **/ˈɡrup ˈʃʌfəl ˈsplɪt/**

A scikit-learn tool that splits data into training and test parts while keeping every row of the same group, such as one customer, in the same part.

## What is **GroupShuffleSplit**?

**GroupShuffleSplit** is a scikit-learn splitter that keeps all the rows of one group, such as one customer or one
household, on the same side of the train-test split. When one customer is on both sides, the model is tested partly on
people it already learned, and its score looks better than it will be.

```python
from sklearn.model_selection import GroupShuffleSplit
visits = [[1], [2], [3], [4], [5], [6]]
customer = ["ana", "ana", "ben", "ben", "cy", "cy"]
splitter = GroupShuffleSplit(n_splits=1, test_size=1, random_state=0)
train, test = next(splitter.split(visits, groups=customer))
print(train, test)   # [0 1 2 3] [4 5]: all of cy's visits in the test part
```

## In a sentence

- “Switching to **GroupShuffleSplit** lowered the test score, because no customer was on both sides anymore.”
- “**GroupShuffleSplit** kept all of Ana's visits in the training rows.”

Level: Freelancer · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=4)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/groupshufflesplit
