## 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 clustering 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 find the two-dimensional theta.
It find the best Theta parameter 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
• Custom Java objects (PoJos)
• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
`static class ` `LinearRegression.Data`
A simple data sample, x means the input, and y means the target.
`static class ` `LinearRegression.Params`
A set of parameters -- theta0, theta1.
`static class ` `LinearRegression.SubUpdate`
Compute a single BGD type update for every parameters.
`static class ` `LinearRegression.Update`
Compute the final update by average them.
`static class ` `LinearRegression.UpdateAccumulator`
Accumulator all the update.
• ### 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)
throws Exception```
Throws:
`Exception`