Hands-On Machine Learning on Google Cloud Platform
by Giuseppe Ciaburro, V Kishore Ayyadevara, Alexis Perrier, Bryan Fry, Antonio Gulli
Data splitting
Let's now split the data for the training and the test model. Training and testing the model forms the basis for further usage of the model for prediction in predictive analytics. Given a dataset of 192 rows of data, we split it into a convenient ratio (say 70:30), and allocate 134 rows for training and 58 rows for testing.
In general, in the algorithms based on artificial neural networks, the splitting is done by selecting rows randomly to reduce the bias. With the time series data, the sequence of values is important, so this procedure is not practicable. A simple method that we can use is to divide the ordered dataset into train and test. As we anticipated, the following code calculates the division point index and separates ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access