0

I'm using time sensitive data and would like to maintain the order of the data but stratifying the data since I've got multiple labels. I haven't found any libraries that allow this.

2 Answers2

0

Hi Juanro could you provide with an example what are you trying to do as it might help to understand the problem in a better way Thanks:

0

Please refer to the train_test_split documentation.

You can do somthing like this:

x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.33, random_state=0, 
                                                    stratify=y)

The stratify = y will give a stratified split with same proportions of class labels as the input dataset.

Rohith
  • 1,008
  • 3
  • 8
  • 19