So great.
That's for the data set.
And now we're going to move on to the implementation.
Simple linear regression
IPython notebook which we're going to open with Google Collaboratory.
So that's simple linear regression.
Let's see how this implementation is structured.
First we're going to import the libraries.
You recognize the first steps of the data
preprocessing phase which we covered in part one.
Second we're going to import the data set.
Then third we're going to split that data set into the training set.
And test set.
Then we're going to train the simple linear regression
model on the training set.
Then we're going to predict the test results.
Then we're going to visualize the training
set results and visualize the test results.
But I don't want to show you this
too much right now because I want to keep the surprise for the end.
And so what we're going to do now is implement
this whole simple linear regression model from scratch together.
And to do so, we are going to create a copy of this file
by clicking here on save a copy in Drive.
This will create a new copy on your drive, in which you will be able
to do some modifications or implement the new model.
Now we just have to do one thing.
It is to remove all the code cells because we were going to re-implement it
from scratch step by step. So let's do this.
We just need to click this trash button here on only the code cells.
Make sure to keep the text in order to highlight you know,
the structure of this implementation.
So there we go.
Let's just delete everything here.
And one last. Perfect.
So now we have the whole structure of the implementation.
You can clearly see the different steps that we're going to implement together.
I will ask you to implement some of them on your own.
And of course then we will implement the solution together.
But that's because I really want you to learn by doing.
I really want you to take action
and try to implement some parts of the models on your own.
All right. Perfect.
So now I want you to think what is going to be our first step here
based on, you know, what we covered in part one.
Well, our first step is obviously the data
preprocessing phase in which we have to import the data set
and maybe use some tools in order to preprocess it the right way.
So that our future simple linear
regression model can be ready to be trained on this data set.
All right.
And now I'm excited because I'm going to show you the efficiency
of the data preprocessing template and how easy and fast
it will be for us to preprocess our data set here.
So what we're going to do now is we're going to go to that previous
folder, you know, the data preprocessing folder which was in part
one data preprocessing accessing the Python section.
And there we go.
Now we're going to open that template.
Perfect.
And you're going to see we're simply going to do some copy paste.
And you'll see that we will only have one thing to change.
And then the data preprocessing phase will be ready and done.
It will be done for us to move on with the next step, which will be,
of course, to train the simple linear regression model on the training set.
All right.
So now I'm going to show you what I've just said.
And simply going to do some copy paste here.
There we go to import first the libraries
and then adding them in a new code cell.
Then to import the data set I'm simply going to copy paste this second code cell.
And you'll see that I will have almost nothing to change.
So creating a new code cell here, pasting it.
And finally,
let's do that final
step of the data preprocessing phase to split the data
set into the training set and the test set to ensure I remind, have the separate
entities where we're going to train separately the model and then evaluate it.
So there we go. Let's paste it.
And now as I've told you, we only have one little thing
to change, which is of course the name of the data set.
And I remind the name of the data set is
we're going to go back to our regression folder here
very quickly two regression simple linear regression Python.
And there we go. Here we are.
And as you can see this is salary underscore data.
So the only thing I have to change here is the name of the data set.
And then voila everything is ready.
The data preprocessing phase is ready.
Because indeed this takes automatically the features
because it selects all the columns except the last one.
And this selects automatically the dependent variable vector
because it selects the last column.
So here of course we have only one feature,
therefore one column for the features and one column for the dependent variable.
But you will see, for example, that for multiple linear regression
it will be exactly the same.
We will have absolutely nothing to change here.
Okay.
So now let me show you the beauty of the result.
Don't forget of course to upload the data set before,
you know running these cells here.
So to upload the data set you indeed need to click this folder here.
Then it's going to connect to a runtime to enable file browsing,
after which you'll be able to upload your data set.
There we go.
So you click this upload button here.
Then you go to, you know, this whole machinery is that folder
which was provided to you in just the previous tutorial.
You know, which you had to download if not already.
So indeed, we're going to go inside this folder.
Then we're going to go to part two regression,
then simple linear regression, then Python.
And there we go.
We select our data set salary data.
We open it and now it is indeed in Google Colab.
So perfect.
And now we're simply going to execute each of these cells first
importing the libraries then importing the data set.
Perfect.
And now splitting the data set into the training set and test set and done.
Now the data preprocessing phase is over and we can move on to the next step
training the simple linear regression model on the training set.