How it works...

After you spend time to train a model, the next step will be to persist the model for future use. In this recipe, we began by training a KMeans model to generate model info for persistence in later steps. Once we have the trained model, we invoke the toPMML() method on the model converting it into PMML for storage. The invocation of the method generates an XML document, then the XML document text can easily be persisted to a file.

Get Apache Spark 2.x Machine Learning 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.