Skip to content
CampusEduX

Problem 2: Apply Agglomerative Clustering with a Fixed Number of Clusters

Easypython
Learn the Concept: Hierarchical Clustering

Problem Description

Write a Python program that applies AgglomerativeClustering with n_clusters=2 to a dataset, and prints the resulting cluster assignments.

Input

A 2D dataset with two visually distinct groups.

Output

The cluster label for each point.

Constraints

  • At least 6 points.

Example Input

text
[[1,1],[2,2],[2,3],[8,8],[9,8],[8,9]]

Example Output

text
Cluster assignments: [0 0 0 1 1 1]

Concepts Covered

AgglomerativeClustering, .fit_predict().

Related Problems

  • Problem 1: Build and Visualize a Dendrogram
    Easy · python
    Solve Problem
  • Problem 3: Compare Different Linkage Methods
    Easy · python
    Solve Problem
  • Problem 4: Manually Calculate Distance Between Clusters
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...