Skip to content
CampusEduX

Problem 2: Implement the Elbow Method

Easypython
Learn the Concept: K-Means Clustering

Problem Description

Write a Python program that calculates and plots the inertia (WCSS) for k values ranging from 1 to 6 on a given dataset, to visually identify the "elbow" point.

Input

A 2D dataset.

Output

A plot showing inertia for each tested value of k.

Constraints

  • At least 10 data points.

Example Input

text
(A dataset with 3 visually distinct groups of points)

Example Output

text
(A line chart showing inertia decreasing as k increases, with a visible "elbow" around k=3)

Concepts Covered

KMeans, looping over k values, plt.plot().

Related Problems

  • Problem 1: Apply K-Means with a Known Number of Clusters
    Easy · python
    Solve Problem
  • Problem 3: Print Centroid Locations and Inertia
    Easy · python
    Solve Problem
  • Problem 4: Visualize K-Means Clusters and Centroids
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...