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 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.