In this video, we will learn how to split the available data and to test and train said.
Then you were a trainee model on the training set and find the mean square error of the test said.
To split the data into disinterring, I prefer to install this package or one other method.
This package is called see it tools.
You know how to install a package.
You can just ride in started out packages.
And within Blackard and double quotation marks.
Right.
See it tools and the T of tool, just capital.
Run this.
You can see on the right see it tools is now available.
We'll just take this check box to make this available.
Now we are going to set a seed, the concept of setting seed is that when splitting the data into a
test and train.
I'll be doing it randomly.
But if I set the seed at a particular value and you said the same seed at the same value, we both will
get the same split.
That is the observation and the training set, which I will get you will get the same observation in
your training said.
So we'll set the he at zero.
So we laid said dot seed again.
And within the blockade, we laid zero.
In Baghdad, we laid zero.
We'll run this.
So we'll see decided zero.
No, we will split the data, right.
Split is equal to sample dark split.
And within a decade, will they be if comma split ratio is equal 2.8?
The S and the art of racial art capital.
Next on this show, a newer, even called split is created and it has blue and false value for each
of the observation.
We will assign crew to the training set and the values that falls will as I need to test it.
So training set is equal to.
And the skill set is equal to subsect.
It's a subset of beef.
So be it.
Colma.
Split.
Equal to equal to two.
So we're checking wherever displayed values, true.
We take out that subset of D.F. and put it into the training set variable so you can see training set
variable is also created.
It does 378 observations.
It will not tell exactly 80 percent of the observations, but merely whichever one you mentioned in
the split ratio, you will have nearly those number of observations and what the remaining values will
assign them to test it.
So Test Underscore said.
Is equal to subsect.
And within that could be if Colma split equal to equal to votes.
And on this, so best set variable is also created.
Now we will run a linear model on the training data set.
We know how to run a linear model that will create a variable.
L.M. underscored A..
And this is equal to L.M..
Within bracket will rate Brice de la Dot.
Goma.
That is equal to training set.
We are not running this model on the complete data that we have.
We are running it only on the 378 observations in the training set.
So let's run this.
The model is fit in the eleven, code eight.
If you want to look at somebody, you can date somebody with a record eleven dress code.
But here we are going to find out the mean square error of the training set.
And it is said so to find means great errors.
We need to first predict the value of price basis.
This fitted model to predict the value.
We'll use a functional predict.
They predict function takes two parameters.
One is the model that we have today, which is a limiter body.
And the other is the data, which is to be used to predict the values of a.
So we'll get these predicted values of the training set into a variable called train underscored a civil
right train, underscored A is equal to predict and within bracket, the first parameter will be LMR,
underscoring the city for model comma, the city data.
So does the training data.
So will they, training on the squad said.
So what this will do is it will take all the independent variables from this say, put it into this
model and predict the value of the independent variable and store it and to train under squaddie.
So let's run this.
So we have train underscored A as another variable.
We'll do this same thing for the test.
It also just in place of train will test.
So we'll get the predicted value of house price for our STW.
Now, the mean square error is the average of difference of these squares, of these predicted values
and the actual values.
So to get that average will rate mean.
And within brackets, we have to square the differences of these.
So it is a difference of training on underscore said dollar price.
So these these are the actual values minus the predicted values which are trained under scored a.
And we want to square these values.
So we'll put another bracket around.
I will square this different.
Run this.
So grindy point six six is the mean squared error on the training data.
So on an average squared distance of the predicted values and the actual values on the training data
is grindy.
Point six six.
Let's do this.
Waddi tested Dolto.
We will use the best set dollar price.
Minus test under squaddie.
So since this test days previously unseen, most probably a model will not work as well on this data.
The main square adder is thirty three point zero four, which means it is performing worse on the unseen.
Do the.
This is as discussed in these two electors also.
So this is all.
We split the data into desert and a train said in.
Are we then done the model on the training set and using the model created on the training, it will
predict the values of the test dependent variable.
We then find the estimated error on this test data.
This estimated at it is to be used when we are comparing different models.