0 votes
in Python Flask by
How do you split training and testing datasets in Python?

1 Answer

0 votes
by

In Python, you can do this with the Scikit-learn module, using the train_test_split function. This is used to split arrays or matrices into random training and testing datasets.

Generally, about 75% of the data will go to the training dataset; however you will likely test different iterations.

Here’s a code example:

X_train, X_test, y_train, y_test = train_test_split(data.data, data.target, test_size=0.4)

...