Welcome back.
Let's continue with data preprocessing.
And let's split the data into test and train sets.
Here, as we did in the previous videos x train, x test, y train and y test equals to train underscore
test underscore split.
This is a function that we used before from the library as key learn.
And we use it in the previous videos.
And in the introductory section of this course for splitting the data between the training and testing.
We have the inputs x and y.
The test the x features all columns except PG.
So here features or all columns except mpg.
Also we have the target y mpg values we want to predict.
The output would be x train, y train x test, and y test X train.
Features for training 80% of data X test features for testing 20% of data.
Y train corresponding mpg miles per gallon and the mileage values for trading.
And those are the corresponding mileage values for testing.
Okay, so we have two um x and y.
Those are the features and target that are passed as parameters for train and test and split.
And the output would be four parameters x train, y test, y train and y test.
We use splitting data to teach the machine learning model, and model learns patterns and relationship
from this data.
So this is a very important step for splitting the data.
And here we have the training set.
So the training set is xtrain and Ytrain.
And testing set is x test and y test variables.
The training set is used to teach the ML model.
And the ML model learns patterns and relationships from this data.
Y.
The testing set used to evaluate the model's performance tests how well the model generalizes to unseen
data.
Preventing cheating.
Model has not seen this data during training.
To see that training and the testing data, we used X train shape and test X test shape run the cell.
We have 313 rows are used for training and xtest 79 rows.
So our testing data contains 79 rows and the training data is 313.
This is used for building the model and the test set used for evaluating the model.
This split is essential for building reliable machine learning models that work while on a new unseen
data.
Preventing overfitting.
Honest.
Evaluation and model selection.