I know how to split the dataset into train and test sets using train_test_split but is there any way that I can split the dataset into three different sets i.e. "Train set", "Test set", and "Validation Set". An example will be enough. Thanks in advance.
train_test_split is just a utility function around
ShuffleSplit, which on its turn just randomly assigns each sample to either
test, taking the desired probability into account.
You can do that however you'd like, and there's no real reason to use that specific function.
Its not too hard to come up with some code that does that for three values or N values, if you rather avoid calling
Here you go.
import numpy as np from sklearn.model_selection import train_test_split X, y = np.arange(10).reshape((5, 2)), range(5) list(y) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42) X_train y_train X_test y_test train_test_split(y, shuffle=False)