Welcome back.
We used numpy library to generate random numbers and create a linear relationship between size and price.
Then we use the data frames from the pandas library to create this table size and the price.
Also, we use the Matplot library to visualize and display the created and generated data into this
chart.
So this chart displays only the first ten results of the data that we created.
Also, this table do the same job.
This.
Thanks for the head function that gets all the first ten rows.
Now let's deep dive into machine learning how to use those data into our model to train and prepare
the model.
The first step is to prepare the data.
We split data into two things.
Two parts training sets to train the model.
Testing set to evaluate performance.
We use train test split for scikit learn.
Let me show you guys.
First we have created two variables x and y.
X equals to data.
Data.
Did you remember the data which is the data frame that we created before.
So if you scroll up we see that we stored all the data inside the data variable.
In order to access the size.
We access it using this angled bracket and y equals to data and accessing the price and square in thousands
of dollars.
Now create those random numbers and random variables again guys X is the feature, Y is the target.
Here we have the split.
We have to split the data at first.
Xtrain Xtest Ytrain y test equals to train test split x y test size and Randomstate.
What does this means?
Train test split is a function from SK learn dot model selection that splits your data set into training,
test set and testing set training set X train and Y train used to train the model.
Testing set X test and Y test are used for for evaluating the model's performance.
The parameters are x, y test size and random set x and y that do constants, the data frame and the
series.
The feature and the target that test size 0.2 is 20% of the data will be for testing and 80% for training.
So let me write this node down.
0.2 equals to 20% of the data will be for testing and 80% for training.
Random state equals to 42 ensures that the split is reproducible.
You get the same split every time you run it.
Okay, it's very simple.
Now checking the numbers of the sample training.
Sample x train dot shape.
Train shape zero and testing the samples Xtest dot shape zero.
The X train shape.
Here we are training.
The model gives the number of rows samples in the training set.
So gives the number of rows in the training set.
And this line gives the number of samples in the test set.
This helps confirm that the split worked and as expected, let's run and here we go.
Training sample 80% and testing sample is 20% okay so this is how we split the data into uh into testing
and training sets.
Again as a quick summary, what we've done before X is the feature, the house size, the y axis and
the y variable is the target which is the price split to 20%.
So the test size would be 20% and 80% for training and random state equals to 42.
Print the number of samples in each set and every time get the same split every time you run it.
Okay, this is how we split the data into testing and to train.