## Class LinearRegression

• ```public class LinearRegression
extends Object```
This example implements a basic Linear Regression to solve the y = theta0 + theta1*x problem using batch gradient descent algorithm.

Linear Regression with BGD(batch gradient descent) algorithm is an iterative algorithm and works as follows:

Giving a data set and target set, the BGD try to find out the best parameters for the data set to fit the target set. In each iteration, the algorithm computes the gradient of the cost function and use it to update all the parameters. The algorithm terminates after a fixed number of iterations (as in this implementation). With enough iteration, the algorithm can minimize the cost function and find the best parameters This is the Wikipedia entry for the `Linear regression` and `Gradient descent algorithm`.

This implementation works on one-dimensional data and finds the best two-dimensional theta to fit the target.

Input files are plain text files and must be formatted as follows:

- Data points are represented as two double values separated by a blank character. The first one represent the X(the training data) and the second represent the Y(target). Data points are separated by newline characters. For example `"-0.02 -0.04\n5.3 10.6\n"`gives two data points (x=-0.02, y=-0.04) and (x=5.3, y=10.6).

This example shows how to use:

- Bulk iterations - Broadcast variables in bulk iterations

• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
`static class ` `LinearRegression.Data`
`static class ` `LinearRegression.Data\$`
`static class ` `LinearRegression.Params`
`static class ` `LinearRegression.Params\$`
`static class ` `LinearRegression.SubUpdate`
• ### Constructor Summary

Constructors
Constructor and Description
`LinearRegression()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static void` `main(String[] args)`
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### LinearRegression

`public LinearRegression()`
• ### Method Detail

• #### main

`public static void main(String[] args)`