O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Cluster plots

We can also plot the assigned clusters with the original data, to see if there are any problems with cluster assignment.

First, we need to append the cluster assignment to the original dataset:

#append the clusters the original data 
append.clust <- data.frame(x, clusters3,clusters5,clusters7) 

For illustration purposes, let's sample from the append.clust dataset. We will set the sample size to 100, but you can set it to any number that makes the diagram readable:

library(cluster)
set.seed(1020)
sampleit <- append.clust[sample(nrow(append.clust), 100), ]

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required