From the course: Complete Your First Project in R

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

How to run a hierarchical clustering algorithm

How to run a hierarchical clustering algorithm

From the course: Complete Your First Project in R

How to run a hierarchical clustering algorithm

- [Instructor] Now let's build a hierarchical clustering algorithm. Make sure to run the top few blocks of code to load in your packages, your data, and clean your data to make it ready to go to cluster on. To begin, building your hierarchial clustering algorithm, you'll need to create a distance_matrix, which will contain the distances between different data points. You can call this distance_mat and assign it to the dist function that you will use on your scaled_data, and you'll use the Euclidean method to run this. What this will do is it will calculate the distances with your scaled_data using the Euclidean method to see how far each data point is from each other. Now that your distance matrix is created, you can build your hierarchical clustering model using the H cluster function. So we'll call this Hierar_clu for hierarchical cluster, and again, use that hclust function and you'll once use this on the distance_matrix you just created, and let's use the averaging method to find…

Contents