Clustering data points using the KMeans algorithm

In this recipe, we will be using the KMeans algorithm to cluster or group data points of a dataset together.

How to do it...

  1. We will be using the cpu dataset to cluster its data points based on a simple KMeans algorithm. The cpu dataset can be found in the data directory of the installed folder in the Weka directory.

    We will be having two instance variables as in the previous recipes. The first variable will be containing the data points of the cpu dataset, and the second variable will be our Simple KMeans clusterer:

            Instances cpu = null; 
            SimpleKMeans kmeans; 
    
  2. Then, we will be creating a method to load the cpu dataset, and to read its contents. Please note that as clustering is an unsupervised method, ...

Get Java Data Science Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.