dimanche 19 mai 2019

How to remerge the X_test and the y_test & the x_train and the y_train after splitting with sklearn?

so i want to perform mean target encoding on Train & test Dataset after splitting them (using stratification) , and in order to do so , have to remerge them together.

how can i d that ? , any suggestion would be much appreciated ? , thank U.

   X_train, X_test, y_train, y_test = train_test_split(R,
                                                target,
                                                test_size=0.25,
                                                random_state=7,
                                                stratify=target)  
   print("Number transactions X_train dataset: ", X_train.shape)
   print("Number transactions y_train dataset: ", y_train.shape)
   print("Number transactions X_test dataset: ", X_test.shape)
   print("Number transactions y_test dataset: ", y_test.shape)

Here's the output:

   Number transactions X_train dataset:  (37779, 89)
   Number transactions y_train dataset:  (37779,)
   Number transactions X_test dataset:  (12593, 89)
   Number transactions y_test dataset:  (12593,)

Aucun commentaire:

Enregistrer un commentaire