2021年2月4日星期四

Split dataset containing multiple labels

I have a dataset with multiple labels, ie for each X I have 2 y and I need to split into train and test set.

I tried with the sklearn function train_test_split():

import numpy as np  from sklearn.model_selection import train_test_split    X = np.random.randn(10)  y1 = np.random.randint(1,10,10)  y2 = np.random.randint(1,3,10)    X_train, X_test, [Y1_train, Y2_train], [Y1_test, Y2_test] = train_test_split(X, [y1, y2], test_size=0.4, random_state=42)  

But I get an error message:

ValueError: Found input variables with inconsistent numbers of samples: [10, 2]  
https://stackoverflow.com/questions/66056596/split-dataset-containing-multiple-labels February 05, 2021 at 10:05AM

没有评论:

发表评论