So I'm going to jump back to my folder.
Part one Data Pre-processing, which is here.
And here we go.
So the categorical data our file is here.
So let's open it. Here it is.
And right now what I'm going to do is I'm going to take this copy.
So you have the same file.
So you can also take it from your folder or take it from the course.
And let's go back to our multiple linear regression file and paste
that here.
Okay.
Then of course we need to change a few things here.
So we need to change the name of our categorical variable.
So in part one it was country.
And here it is state.
Okay.
Same here.
We need to change country by state.
Let's not forget to align this.
This is very important in R.
And then any programing language.
Here we go there.
And now we need to change the levels.
So before you know the categorical variable was the countries.
And the three categories were France Spain and Germany.
And here our three categories are New York California and Florida.
So let's do it on our dataset.
Actually I will close that because we no longer need it.
So here are levels are we said New York.
California. And.
Florida.
Okay.
And then the labels that is the numeric numbers
which are actually factors, the numeric factors
that are going to replace this three text here New York California and Florida.
Are these numbers you choose here for labels.
So here we have 123.
That means that New York is going to be one.
California is going to be two and Florida is going to be three.
You're going to see I'm going to select this and execute.
All right.
And now let's look at our data set.
As you can see the state is now encoded with the 123 values.
So one for New York, two for California and three for Florida.
Let's go back. Okay.
So the encoding is done.
And that's a much better thing for our model.
Now our model has a greater chance to work.
And now the last thing we need to do is to split the data
sets into the training set and the test set.
So here let's not forget to change the name of the dependent variable here,
which is not purchased but profit.
All right.
And then we need to change a split ratio if necessary.
Let's see. We have 50 observations.
So a good split would be to have
40 observations in the training set and ten observations in the test set.
So that makes actually an 80% split ratio 80% going to the training set.
And this is already what we have. Perfect.
So we don't have to do anything here for the split ratio.
And we are ready to take all of these.
And execute.
And here we go.
Let's have a look at our training set and our test set.
Here it is.
That's the training set.
Okay.
So it contains 40 entries for the observations.
Great.
We have our encoded variable for state.
That's perfect.
And then a test set that contains ten observations.
And everything looks fine.
All right so let's go back to multiple linear regression.
And the last step is feature scaling.
But as for simple linear regression we won't need to apply
feature scaling manually.
This will be taken care of with the function that we're going to use
to fit multiple linear regression to our training set.
So we're all fine. We're all good here.
We are ready to move on to the next step.
And that's what we're going to do in the next tutorial.
Thank you for watching this one and I look forward to seeing you in the next one.
Until then, enjoy machine learning.