All right.
And now let's do the same for our dependent variable vector.
And you know this will be exactly the same.
We'll just have to change one little thing.
So I'm going to copy this and paste it right here.
And now according to you based on what I've just explained,
what do we have to change here in order to get the dependent variable vector,
which is most of the time in in our data set.
Indeed, the last column.
Okay.
So let's see first okay.
We have to take our data set
because we want to extract this text column from our data set.
Then we have to use I look to collect indexes of the rows and columns we want.
Then we indeed want to take all the rows of the data set,
because we want to take all the purchase decisions of these customers,
whether or not they decided to purchase yes or no the product.
So okay, we want all the rows.
But then which comes do we want to get here?
Well we only want to get the last column.
So according to you what is index.
We need to input here in order to get only the last column.
Well this time since we only want to get one column,
we definitely don't want to get a range.
And therefore I'm going to remove the range here.
And then what are we left here?
We're left here with minus one.
And as I've told you, minus one is exactly the index of the last column.
So there we go.
That's exactly what we need to create this dependent variable vector.
And thus this line of code is done.
Congratulations.
Now you know how to import data set.
Create a matrix of features and create a dependent variable vector.
And the cherry on the cake
is that any time we want to create these for your data sets,
you won't have anything to change, because this will automatically take
all the first columns for the matrix of features
and the last column for the dependent variable vector.
All right.
So now I'm going to show you indeed that x and y will be well created.
And in order to do this we're going to add a new code cell here
inside to which we're just going to print.
So that's the famous print function which allows you to print anything,
whether it is a text or, you know, an array like x or vector like y.
So we're going to first print x
and then I'm going to add a new code cell here where we're going to print y.
And this is just to show you that indeed x and y will
well be created with this code okay.
So let's do this. Now time for the fun part.
We're going to execute all the cells here.
Because you know so far we've just written the implementations.
But we have to run the cells in order to build all this.
So let's first run this code cell importing the libraries.
All right. So import it.
As you can see if I click here.
Yes this one here means it is executed.
Now time to run the second one.
But before running this we have to do something very important.
It is to upload this data set here in CSV
format inside our Google Colab notebook.
And to do this you just need to click files here.
You know this little folder, then upload.
Then you're going to go to this whole machine learning
is that folder containing all the codes and data set and which was provided to you
in the first section.
And I will give it to you again in every sections
that you make sure not to miss it.
And inside this folder you're going to go now to import one data preprocessing.
In order to get indeed that data CSV
file containing the data set we are importing right now.
So open and now the data set will be indeed in Google Colab your notebook.
And so now we can run this cell to import it.
And there we go. It is already import it.
You know it is executed.
So now we're going to execute this cell in order
to print the matrix of features X, just to check that indeed
we get all the first columns inside this matrix.
And indeed well let's check the data set once again.
Remember the first column is meaning the features we wanted to get into.
This matrix X are first country, second age, and third to salary.
These are the three columns.
And indeed inside X we have first the country column
with all the countries of these customers their age,
and in the third column their salary or their estimated salary.
So that's perfect.
We get indeed the matrix of features X containing all the features
or also called the independent variables.
All right.
And now let's run this cell to print y the dependent variable vector.
And indeed it gets the dependent variable vector containing all the decisions
whether or not the customers purchased the product.
Right. We can check. No. Yes. No no
no. Yes.
No no okay. So that's in the same order.
That's perfect.
We now have our data
set our matrix of features X and our dependent variable vector y.
And lastly let me remind why we had to create these two entities.
That's because the way we're going to build our future machine
learning models expects exactly these two entities in their inputs.
You know, we will use some classes to build these models.
And these classes don't expect the data set as a whole,
but these two separate entities, and that's
the only reason why we had to create these two separate entities.
So now you know, and therefore congratulations, not only you improve
your knowledge of machine learning, but also you now know how to import
a data set and create a matrix, a feature and a dependent variable vector.
So now we're going to proceed to the next step which is a new tool
which I'm going to teach you.
And that is taking care of missing data.
Indeed, as you can see the data set contains some missing data.
Right here. You can see this is an empty cell.
So I will teach you exactly how to handle that case,
which happens most of the time in data sets.
So let's do this in a next tutorial.
And until then enjoy machine learning.