partitioning the data randomly partitioning the data in order to test the model may be achieved easily with sklearn' function train_test_split for examplesuppose that the training data is described by the matrix of explanatory variables and the vector of responses then the following code splits the data set into training and testing setswith the testing set being half of the total set from sklearn model_selection import train_test_split x_train x_test y_train y_test train_test_split (xytest_size as an examplethe following code generates synthetic data set and splits it into equally-sized training and test sets syndat py import numpy as np import matplotlib pyplot as plt from sklearn model_selection import train_test_split np random seed ( =np pi *( np random random (size =( , )- =np cos( [, ])*np sin( [, ]>= x_train x_test y_train y_test train_test_split (xytest_size = fig plt figure (ax fig add_subplot ( ax scatter x_train y_train == , x_train y_train == , =' 'marker =' ',alpha = ax scatter x_train y_train == , x_train y_train == , =' 'marker =' ',alpha = ax scatter x_test y_test == , x_test y_test == , =' 'marker =' ',alpha = ax scatter x_test y_test == , x_test y_test == , =' 'marker =' ',alpha = plt savefig ('sklearntraintest pdf ',format ='pdf 'plt show ( standardization in some instances it may be necessary to standardize the data this may be done in sklearn with scaling methods such as minmaxscaler or standardscaler scaling may improve the convergence of gradient-based estimators and is useful when visualizing data on vastly different scales for examplesuppose that is our explanatory data ( stored as numpy array)and we wish to standardize such that each value lies between and