Skip to content
C

Problem 2: Implement the Elbow Method

Easypython

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().

Input (stdin)

Output

Run your code to see output here...