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

Fitting the model to the training data

Since you have the coefficients, you could actually predict the cluster membership manually via code. You would probably want to do this if you were implementing cluster assignment in a production environment. However, it is easier to use a predict method.

Let's fit the model first to the training data. We can print out some of the fitted values just to see what was generated. The last column indicates the cluster assignment for that observation:

fitted <- predict(model, df_normal)SparkR:::registerTempTable(fitted,"fitted_tbl")head(fitted) 

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