Creating a linear regression model with MLib

In this recipe, you will see how you can use a linear regression model to model with MLib.

Getting ready

  1. You will be using the Maven project you created in the recipe named Solving simple text mining problems with Apache Spark. If you have not done so yet, then follow steps 1-6 in the Getting ready section of that recipe.
  2. Go to https://github.com/apache/spark/blob/master/data/mllib/ridge-data/lpsa.data, download the data, and save as lr-data.txt in the data folder of your project that you created by following the instruction in step 1. Alternatively, you can create a text file named lr-data.txt in the data folder of your project and copy-paste the data from the aforementioned URL.
  3. In the package that you ...

Get Java Data Science Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.