Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
What is a Hierarchical Clustering? | Hierarchical Clustering
Cluster Analysis in Python
course content

Course Content

Cluster Analysis in Python

Cluster Analysis in Python

1. K-Means Algorithm
2. K-Medoids Algorithm
3. Hierarchical Clustering
4. Spectral Clustering

What is a Hierarchical Clustering?

In this section, we will consider the hierarchical clustering - one more clustering algorithm.

How does this algorithm work? We will consider the AGNES (Agglomerative Nesting clustering) algorithm. It can be called a bottom-up approach since, in the beginning, all the points are in separate clusters. Then, some clusters are joined based on linkages, until all the necessary number of clusters will be reached.

In Python, the Hierarchical clustering algorithm is implemented within the AgglomerativeClustering function from the sklearn.cluster library. Unlike in the two previous sections, to predict the labels there you need to use the .fit_predict method with data as a parameter. Let's rewrite the necessary actions step by step:

  1. Create an AgglomerativeClustering model object with a necessary number of clusters (n_clusters) and parameters set (will be considered in the next chapters).
  2. Fit the data and predict the labels using the .fit_predict() function passing data as the parameter.

Agglomerative Clustering has many parameters, among them are n_clusters (as in the previous sections), linkage, affinity, and so on... We will consider them in future chapters.

Task

Given the 2-D dataset of points (training dataset). The scatter plot is shown below.

[object Object]

You need to perform a Hierarchical Clustering for this data. Follow the next steps:

  1. Import AgglomerativeClustering function from sklearn.cluster.
  2. Create AgglomerativeClustering object model with 3 clusters.
  3. Apply .fit_predict() method to model with data as a parameter. Add the result as 'prediction' column to data.
  4. Build a scatter plot of data with 'x' column on the x-axis, 'y' column on the y-axis, and each point colored with respect to the 'prediction' column.

Task

Given the 2-D dataset of points (training dataset). The scatter plot is shown below.

[object Object]

You need to perform a Hierarchical Clustering for this data. Follow the next steps:

  1. Import AgglomerativeClustering function from sklearn.cluster.
  2. Create AgglomerativeClustering object model with 3 clusters.
  3. Apply .fit_predict() method to model with data as a parameter. Add the result as 'prediction' column to data.
  4. Build a scatter plot of data with 'x' column on the x-axis, 'y' column on the y-axis, and each point colored with respect to the 'prediction' column.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 3. Chapter 1
toggle bottom row

What is a Hierarchical Clustering?

In this section, we will consider the hierarchical clustering - one more clustering algorithm.

How does this algorithm work? We will consider the AGNES (Agglomerative Nesting clustering) algorithm. It can be called a bottom-up approach since, in the beginning, all the points are in separate clusters. Then, some clusters are joined based on linkages, until all the necessary number of clusters will be reached.

In Python, the Hierarchical clustering algorithm is implemented within the AgglomerativeClustering function from the sklearn.cluster library. Unlike in the two previous sections, to predict the labels there you need to use the .fit_predict method with data as a parameter. Let's rewrite the necessary actions step by step:

  1. Create an AgglomerativeClustering model object with a necessary number of clusters (n_clusters) and parameters set (will be considered in the next chapters).
  2. Fit the data and predict the labels using the .fit_predict() function passing data as the parameter.

Agglomerative Clustering has many parameters, among them are n_clusters (as in the previous sections), linkage, affinity, and so on... We will consider them in future chapters.

Task

Given the 2-D dataset of points (training dataset). The scatter plot is shown below.

[object Object]

You need to perform a Hierarchical Clustering for this data. Follow the next steps:

  1. Import AgglomerativeClustering function from sklearn.cluster.
  2. Create AgglomerativeClustering object model with 3 clusters.
  3. Apply .fit_predict() method to model with data as a parameter. Add the result as 'prediction' column to data.
  4. Build a scatter plot of data with 'x' column on the x-axis, 'y' column on the y-axis, and each point colored with respect to the 'prediction' column.

Task

Given the 2-D dataset of points (training dataset). The scatter plot is shown below.

[object Object]

You need to perform a Hierarchical Clustering for this data. Follow the next steps:

  1. Import AgglomerativeClustering function from sklearn.cluster.
  2. Create AgglomerativeClustering object model with 3 clusters.
  3. Apply .fit_predict() method to model with data as a parameter. Add the result as 'prediction' column to data.
  4. Build a scatter plot of data with 'x' column on the x-axis, 'y' column on the y-axis, and each point colored with respect to the 'prediction' column.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 3. Chapter 1
toggle bottom row

What is a Hierarchical Clustering?

In this section, we will consider the hierarchical clustering - one more clustering algorithm.

How does this algorithm work? We will consider the AGNES (Agglomerative Nesting clustering) algorithm. It can be called a bottom-up approach since, in the beginning, all the points are in separate clusters. Then, some clusters are joined based on linkages, until all the necessary number of clusters will be reached.

In Python, the Hierarchical clustering algorithm is implemented within the AgglomerativeClustering function from the sklearn.cluster library. Unlike in the two previous sections, to predict the labels there you need to use the .fit_predict method with data as a parameter. Let's rewrite the necessary actions step by step:

  1. Create an AgglomerativeClustering model object with a necessary number of clusters (n_clusters) and parameters set (will be considered in the next chapters).
  2. Fit the data and predict the labels using the .fit_predict() function passing data as the parameter.

Agglomerative Clustering has many parameters, among them are n_clusters (as in the previous sections), linkage, affinity, and so on... We will consider them in future chapters.

Task

Given the 2-D dataset of points (training dataset). The scatter plot is shown below.

[object Object]

You need to perform a Hierarchical Clustering for this data. Follow the next steps:

  1. Import AgglomerativeClustering function from sklearn.cluster.
  2. Create AgglomerativeClustering object model with 3 clusters.
  3. Apply .fit_predict() method to model with data as a parameter. Add the result as 'prediction' column to data.
  4. Build a scatter plot of data with 'x' column on the x-axis, 'y' column on the y-axis, and each point colored with respect to the 'prediction' column.

Task

Given the 2-D dataset of points (training dataset). The scatter plot is shown below.

[object Object]

You need to perform a Hierarchical Clustering for this data. Follow the next steps:

  1. Import AgglomerativeClustering function from sklearn.cluster.
  2. Create AgglomerativeClustering object model with 3 clusters.
  3. Apply .fit_predict() method to model with data as a parameter. Add the result as 'prediction' column to data.
  4. Build a scatter plot of data with 'x' column on the x-axis, 'y' column on the y-axis, and each point colored with respect to the 'prediction' column.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

In this section, we will consider the hierarchical clustering - one more clustering algorithm.

How does this algorithm work? We will consider the AGNES (Agglomerative Nesting clustering) algorithm. It can be called a bottom-up approach since, in the beginning, all the points are in separate clusters. Then, some clusters are joined based on linkages, until all the necessary number of clusters will be reached.

In Python, the Hierarchical clustering algorithm is implemented within the AgglomerativeClustering function from the sklearn.cluster library. Unlike in the two previous sections, to predict the labels there you need to use the .fit_predict method with data as a parameter. Let's rewrite the necessary actions step by step:

  1. Create an AgglomerativeClustering model object with a necessary number of clusters (n_clusters) and parameters set (will be considered in the next chapters).
  2. Fit the data and predict the labels using the .fit_predict() function passing data as the parameter.

Agglomerative Clustering has many parameters, among them are n_clusters (as in the previous sections), linkage, affinity, and so on... We will consider them in future chapters.

Task

Given the 2-D dataset of points (training dataset). The scatter plot is shown below.

[object Object]

You need to perform a Hierarchical Clustering for this data. Follow the next steps:

  1. Import AgglomerativeClustering function from sklearn.cluster.
  2. Create AgglomerativeClustering object model with 3 clusters.
  3. Apply .fit_predict() method to model with data as a parameter. Add the result as 'prediction' column to data.
  4. Build a scatter plot of data with 'x' column on the x-axis, 'y' column on the y-axis, and each point colored with respect to the 'prediction' column.

Switch to desktop for real-world practiceContinue from where you are using one of the options below
Section 3. Chapter 1
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt