0
$\begingroup$

I have come across sklearn.model_selection.train_test_split as a method to split up the train and testing dataset.

Furthermore they have a stratify which you can set to the labels to ensure your train and test data set have approximately the same proportion of labels of each type.

My question is what if you have more than one type of label for your data, so that your labels are not a size len(dataset) x 1 but a size of len(dataset) x m where m is the number of your label types. What tool can you use to stratify (and split) your dataset in the multilabel case.

$\endgroup$
  • 1
    $\begingroup$ Maybe you could merge the columns that contain the labels, do the stratification, and unmerge them afterwards? $\endgroup$ – Pallie Apr 23 '19 at 12:11
1
$\begingroup$

Looks like you have a set of "dummy" variables which were previously the same variable.

What you could do is to return to the original variable, get the stratified data, and then rerun the one-hot encoding to have the variables again.

Remember: If your dataset is very balanced, your results with and without stratification will be almost the same.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.