Hello my friends, and welcome
to this new practical activity on multiple linear regression.
So in this new section
we're going to learn together how to build a multiple linear regression model
on the same data set that was introduced by Kirill in the previous lectures.
And just before we start,
I just want to make sure that everyone here is on the same page.
This is the whole machine learning dataset folder containing all the codes
and data sets.
And right before this tutorial, I give you again the link to this folder.
So make sure to connect to that link.
And now we should be all on the same page ready to start this new machine
learning model, which is of course in part two regression.
And now we're going to go of course to multiple linear regression folder.
And we're going to start with Python to implement this model.
All right so this is the data set.
And this is the Python implementation in Ipynb format
which you can either open with Google Collaboratory or Jupyter Notebook.
Make sure you also have the folder
downloaded on your machine so that you can indeed get these files.
All right.
So before we start the implementation,
let me just explain again what this data set is about.
So remember venture capital is funds hired you
as a data scientist to train a machine learning model.
And actually a multiple linear regression model to understand
the correlations between these features,
which are the spend in R&D, administration and marketing.
And as well as the state and the profit of what, of 50 startups.
So in this data set, it's
very important to understand that each row corresponds to a certain startup.
And for each startup, well, you data scientist collected the following data.
R&D spend, administration spend, marketing spend
and the state of the startups.
And of course their profit.
Because the goal for this VC fund
is to figure out in which startup to invest based on these information.
So these are all information that we already know from 50 startups.
And therefore, if you manage to train a machine learning model that can understand
well these correlations, well, for the next step,
you'll be able to deploy this model on these features
to predict what sort of profit this new startup might generate.
Okay.
So for this fund, you definitely want to build an accurate model.
All right.
And now we can start the implementation.
But before we start
I would like you to figure out
what are going to be the first steps of this implementation.
You know, before I show it to you.
All right.
So first, I hope that the first thing that came to
your mind is that indeed the first step is the data preprocessing phase.
And remember, in the data preprocessing phase we start by importing the libraries.
That's for sure.
Then we're going to import the data set.
That's even more for sure.
And then we will split the data set between the training set and the data set.
Because indeed we want to train separately our model
and evaluate its performance on a separate set.
Okay. So that's always required.
But then is there something else that we have to do here.
Well, to answer this question let's have a look
at the columns one by one, starting with R&D spend.
So R&D spent is an empirical column you know containing numerical values.
And when we scroll down you know we can scroll down
because there are only 50 observations corresponding to 50 startups.
And we can see that here there is no missing data.
So all good then second column the administration spent
you know, all the spending administration like paying employee salaries
or anything else.
So this column is once again numerical with numerical values.
And there is once again no missing data.
Perfect.
So so far are three steps of the data preprocessing template
argued the next one column in marketing spend.
Well same numerical column with no missing data.
Oh, good.
And now this column.
You know the last feature.
Notice once again
that all the features are in the first columns
and the dependent variable which you want to predict in the last column.
So back to this stage feature what reflexes you have in your mind.
Now you should have the reflex.
If you paid attention to parts one they depressing.
Basically, the question I'm asking now is do we need to apply
a certain tool of our data preprocessing toolkit,
which we built in part one into this data set?
Well, here the answer is obviously yes,
because indeed this state column is not numerical.
It actually has some categories.
It has three categories which are New York, California and Florida.
And therefore
that's exactly the same situation as in parts when data preprocessing.
There is no order relationship between these
three states New York, California and Florida.
And therefore we will have to apply one hot encoding to that state column,
and therefore will have to grab a tool of our data preprocessing toolkit.
And that's why I prepared it here in order to indeed one hot encode
that categorical variable, the state variable.
All right.
And then the profit is fine.
It is numerical.
And besides there is once again no missing data.
So that's what you know you must do.
First you need to have a look at your data set.
If it is not too long, you can check that there is no missing data
like we just did.
If it is too long, then I recommend to apply your data
preprocessing tool that handles missing data and deploy it on this data set.
And then you must check if any feature is categorical.
And here we could check that very easily.
The state is categorical.
So we're going to apply our one hot encoding tool
of our data preprocessing toolkit on this state column.
And then of course we will apply all the rest of the three
essential steps of our data preprocessing template.
And once again we will do that in a flashlight because this is a template
where we only have one thing to change, which is the name of the dataset.