-2
$\begingroup$

I need to x_train, X_validate, and y_test. This is the code I have so far, but I do not think it is right. Could someone please guide me? I typically only see train and test, not all 3 together.

X_train, X_test, y_train, y_test = train_test_split(X.T, y.T, test_size=0.2, random_state=1)
X_train, X_val, y_train, y_val = train_test_split(X_train, y_train, test_size=0.25, random_state=1)
$\endgroup$
1
  • $\begingroup$ This isn't the place for coding questions. $\endgroup$ – astel Jul 17 '20 at 1:45
1
$\begingroup$

Your code above is on the right track, in the sense that scikit-learn's train_test_split does only produce train and test sets for each of X and y.

To get the validation you're looking for, we'd often use cross-validation (whether manually or using a module like GridSearchCV) with X_train and y_train as inputs. Then we'd do final predictions for measuring test-set AUC or accuracy using X_test and y_test.

$\endgroup$
1
  • $\begingroup$ Would you mind typing the code out? I've never used train_test_split before. The instructions of the practice were to "do train/validate/test split" $\endgroup$ – hed Jul 17 '20 at 1:51

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