Answers.Body: <p>You can use the scikit learn <code>train_test_split()</code> by passing the <code>stratify</code> argument with the class value.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-04-27T21:52:05.847Z
Answers.Text: This can become a more complicated problem , if there is imbalance in the distribution of classes.
Answers.UserDisplayName: ML_Passion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-04T14:27:59.540Z
Answers.LastActivityDate: 2022-12-04T14:27:59.540Z
Answers.UserDisplayName: Arun Aniyan
Body: <p>I have a dataset for Object Detection with YOLO format labels, each imagine can have occurences of different classes and multiple occurences of the same class.</p>
  <p>How can the dataset be divided into Training, Validation, and Test sets so that each contains about the same percentage of occurences per class?</p>
  
Tags: <datasets><object-detection><yolo>
Title: Split dataset into Train/Validation/Test for Object Detection
UserDisplayName: 1stTimeStackOverflow
ThreadText: # Split dataset into Train/Validation/Test for Object Detection
  
  (Asked by: username_0 on 2022-12-04)
  
  I have a dataset for Object Detection with YOLO format labels, each imagine can have occurences of different classes and multiple occurences of the same class.
  
  How can the dataset be divided into Training, Validation, and Test sets so that each contains about the same percentage of occurences per class?
  
  **Tags:** datasets, object-detection, yolo
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-12-04. Score: 1
  
  You can use the scikit learn `train_test_split()` by passing the `stratify` argument with the class value.
  
  > **Comments:**
  > **username_2**: This can become a more complicated problem , if there is imbalance in the distribution of classes.  
  
  ---
  
  