Skip to content
CampusEduX

Problem 3: Print Centroid Locations and Inertia

Easypython
Learn the Concept: K-Means Clustering

Problem Description

Write a Python program that fits a K-Means model with k=3 to a dataset and prints the final centroid locations and total inertia.

Input

A dataset with 3 visually distinct groups.

Output

The centroid locations and inertia value.

Constraints

  • At least 9 data points.

Example Input

text
(9 points forming 3 visually distinct groups)

Example Output

text
Centroids: [[...], [...], [...]] Inertia: 12.5

Concepts Covered

.cluster_centers_, .inertia_.

Related Problems

  • Problem 1: Apply K-Means with a Known Number of Clusters
    Easy · python
    Solve Problem
  • Problem 2: Implement the Elbow Method
    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...