Hello and welcome to this art tutorial.
In the following tutorials we will be implementing multiple linear
regression in R.
And right now, as usual, we are going to start with the basics
which is to set our folder as working directory.
So right now I'm on my desktop.
I'm going to my Machine Learning A-Z folder.
Then part two regression.
And then we want to go to multiple linear regression.
And here is the folder.
Make sure that you have the 50 ups dot csv file.
And if that's the case you're ready to click on this more button here
to set the folder as working directory.
All right.
Now let's start with step one which is to prepare the data
to make our multiple linear regression ready to be built.
So as usual we are going to use our template,
the data pre-processing template that we made in part one.
And we are just going to copy this
copy and paste it here.
All right.
And now let's take care of the few things to change.
So first we will change the name of the data set
which is here 50 strips.
All right 50 startups dot CSV.
We can select this and execute to have a look at our data set.
Here it is.
And that's the data set.
I'll remind what this data set is about.
So this contains informations of startups actually 50 startups.
And these informations are some amount of money spent.
So for example there's the amount spent in R&D administration marketing.
And finally there is also the state in which the startup operates.
And finally we have a last column here which is the profit.
And that's the profit we want to predict with our multiple linear
regression models.
And we want to predict that profit based on this
independent variables which are the earned spend,
the administration marketing spend and the state.
So we are doing this because we are doing a mission for investors
who want to know in which startup they should invest their money.
And so not only they want to predict the future
profits for new startups based on the same information,
but also they want to see
which independent variable has the highest effect on the profit
and which one governs the relationship between the profit
and those independent variables.
Is there an independent variable that has a highest effect than another one?
Does the state in which the started operates have an impact on the profit?
We'll find that out thanks to our multiple linear regression model in R.
And thanks to this model,
the investors will be able to draw some insights from our results.
Okay, so now the
next step step of the first step data pre-processing is to split
the data set into the training set and the test set.
But is it this step step we need to do right now.
I know that
the template is suggesting that, but let's not forget that in our data set
we have one specific variable which should strike our attention.
Well it's this one.
It's the state variable
because it contains categories which means it's a categorical variable.
And remember
when we have a categorical variable like this with categories written in text.
This would cause some issues in our machine learning model equations.
Because how do you want
to make a linear equation with one of the variable written as text?
Wouldn't make any sense.
So what we're going to do, of course, is to
encode the state variable.
And to do this
we are going to use what we learned in part one data pre-processing only.
We didn't include that in the template, because this will actually be
one of the only examples where we'll need to encode our categorical data.
We put it in a separate file.
And so right now we are going to open the separate file.