Exercise: Creating and Analyzing a KMeans Model

Check your understanding of data clustering techniques.

We'll cover the following

Let’s practice what we’ve learned so far.

Tasks

Refactor the Python code below to implement the following tasks:

  • Create a KMeans cluster using one cluster and the dataset given in data.
  • Calculate and print the cluster_centers_ of the model.
  • Evaluate the model’s performance by calculating and printing the inertia_ attribute of the model.
  • Print an array of the inertia values against the number of clusters, and determine the optimal number of clusters using the elbow technique.

Coding workspace

The provided workspace contains the required libraries and datasets. Try to code the solution for the tasks mentioned above.

Get hands-on with 1200+ tech skills courses.