Intercept

The final parameter option for the linear model is whether to use an intercept or not. An intercept is a constant term that is added to the weight vector, and effectively accounts for the mean value of the target variable. If the data is already centered or normalized, an intercept is not necessary; however, it often does not hurt to use one in any case.

We will evaluate the effect of adding an intercept term to the model here:

Scala

object LinearRegressionCrossValidationIntercept{   def main(args: Array[String]) {     val data = LinearRegressionUtil.getTrainTestData()     val train_data = data._1     val test_data = data._2     val iterations = 10     val step = 0.1     val paramsArray = new Array[Boolean](2)     paramsArray(0) = true  paramsArray(1) ...

Get Machine Learning with Spark - Second Edition now with O’Reilly online learning.

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