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

Running the k-means model

Now that the data is normalized, we can move on to model building.

SparkR contains a k-means model which is very similar in syntax to the base k-means model. There is an additional parameter, InitMode, in which you can specify that a random seed be generated for generating the starting cluster. As of this version of SparkR, you cannot manually set a seed. Therefore, be aware that the clusters generated may be slightly different each time the model is run.

Additionally, you can specify the outcome variable (glucose) as well as the variables to be clustered, so that you can evaluate the fit of the cluster model.

For illustration purposes, we will generate a model of five clusters.

Use summary(model) to display the ...

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