How it works...

To be able to compare with other regression methods and see the shrinkage effect, we used the housing data again and trained a model using RidgeRegressionWithSGD.train. After fitting the model, we output intercept and parameter weights for the model that we just trained. We then proceeded to predict the values using the .predict() API. We printed the predicted values and visually inspected the first 20 numbers before outputting the MSE and RMSE.

The Signature for this method constructor is as follows:

new RidgeRegressionWithSGD()

These parameters ultimately control the fit, and hence, some level of experimentation is required to achieve a good fit. We saw the first two parameters in the previous recipe. The third parameter ...

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.