Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Machine Learning for Healthcare Analytics Projects

You're reading from  Machine Learning for Healthcare Analytics Projects

Product type Book
Published in Oct 2018
Publisher Packt
ISBN-13 9781789536591
Pages 134 pages
Edition 1st Edition
Languages

Splitting the dataset into training and testing datasets

Before we can begin training our neural network, we need to split the dataset into training and testing datasets. This will allow us to test our network after we are done training in order to determine how well it will generalize new data. This step is incredibly easy when using the train_test_split() function provided by scikit-learn. So, we reserve some of the data that we have to test so that we can see how well our algorithm is performing.

  1. To do that, we will import the model_selection package from sklearn. From this package, we're going to use the train_test_split function. The following lines of code show us how to split the data into the required training and testing sets:
from sklearn import model_selection
# split the X and Y data into training and testing datasets
X_train, X_test, Y_train, Y_test = model_selection...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}