Skip to Content
Java: Data Science Made Easy
book

Java: Data Science Made Easy

by Richard M. Reese, Jennifer L. Reese, Alexey Grigorev
July 2017
Beginner to intermediate
715 pages
17h 3m
English
Packt Publishing
Content preview from Java: Data Science Made Easy

Clustering as dimensionality reduction

Clustering can be seen as a special kind of dimensionality reduction. For example, if you group your data into K clusters, then you can compress it into K centroids. Once we have done it, each data point can be represented as a vector of distances to each of those centroids. If K is smaller than the dimensionality of your data, it can be seen as a way of reducing the dimensionality. 

Let's implement this. First, let's run a K-means on some data. We can use the performance dataset we used previously.

We will use Smile again, and we already know how to run K-means. Here is the code:

double[][] X = ...; // data int k = 60; int maxIter = 10; int runs = 1; KMeans km = new KMeans(X, k, maxIter, runs);
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Data Science Cookbook

Java Data Science Cookbook

Rushdi Shams
Java for Data Science

Java for Data Science

Walter Molina, Richard M. Reese, Shilpi Saxena, Jennifer L. Reese

Publisher Resources

ISBN: 9781788475655Supplemental Content