How it works...

We started by loading the wine quality dataset into a DataFrame via Databrick's spark-csv library. The next step was to attach a unique identifier to each row in our dataset to later match the predicted quality to the actual quality. The raw data was converted to labeled points so it can be used as input for the streaming linear regression algorithm. In steps 9 and 10, we created instances of mutable queues and Spark's QueueInputDStream class to be used as a conduit into the regression algorithm.

We then created the streaming linear regression model, which will predict wine quality for our final results. We customarily created training and test datasets from the original data and appended them to the appropriate queue to start ...

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.