Hello and welcome to this are tutorials.
So in the previous tutorials we solved our business problem in Python
using hierarchical clustering.
And this time we're going to solve it in R.
And you're going to see that it's exactly the same.
We are going to import our model data set first.
Then we're going to use the dendrogram to find the optimal number of clusters.
Then we will fit hierarchical clustering to our small data sets.
And then finally we will visualize our results.
So in this tutorial
we're going to do the first step which is to import the model data sets.
So let's start doing it right now.
But before that let's not forget to set our working directory.
So here I'm on my desktop.
This is my machine learning A-Z folder.
Let's open it then let's go to part three clustering then hierarchical clustering.
And now we click on this more button.
Here we click on Settings Working directory.
And that sets our hierarchical clustering folder as working directory.
So let's make sure we have our small data set in the folder.
Here it is perfect. We are ready to start.
Okay so let's introduce a new section with the comments.
Importing the small data set.
Here we go.
And now let's import our data set.
So we create this new variable.
Data set equals red dot CSV.
And in parenthesis we put the name of our data set model CSV in quotes.
Okay so let's select this line and execute.
And now our data set appears in data.
So let's click on it. And here it is.
So for those of you who didn't follow the Python tutorials,
I'll just give a quick reminder of what this dataset is about.
So basically these are informations of customers in a model which are customers
that not only subscribe to the membership card, but also come often to the mall
and the mall gathered some informations of 200 of these customers,
their gender, their age, their annual income.
And then for each of these customers, they computed a spending score.
So this spending score takes values between 1 and 100.
And the closer the spending score is to one, the less the customer spends
and the closer the spending score is to 100, the more the customer spends.
Okay. So we have these informations.
And now our mission is to find some groups of customers.
But since we have no idea of what kind of groups we're looking for,
or even the number of groups of customers we're looking for,
this specifically makes this business problem
a clustering problem because we don't know the answers.
We don't know the final result.
And more precisely, we don't know the final categories of our customers.
Okay. So we imported our data set.
And now what we have to do is to prepare our data because we want to do this
clustering only based on the annual income and the spending score.
So let's create a new variable x
equals data set.
And then in square brackets we're going to put the two indexes
of our columns of interest which are.
Let's see.
Let's go back to our data set indexes.
And our start one.
So customer ideas index one gender as index two.
Age as index three.
Annual income as index four and spending scores index five.
Okay.
So here in the square brackets we add four column five.
That takes our columns annual income and spending score.
And now let's select this line of code and execute it.
And here it is.
Our x variable appears in the data.
Let's click on it to make sure everything is fine.
Okay perfect.
We have our two columns Annual Income and Spending Score and our 200 observations.
Perfect.
So we completed our first step.
So that's the end of this tutorial.
And in the next tutorial things are going to get more interesting.
We're going to use the dendrogram to find the optimal number of clusters.
And you're going to see what a dendrogram looks like in R.
Thank you for watching this video and I look forward to seeing you
in the next tutorial.