Package weka.core.matrix

# Class LinearRegression

java.lang.Object
weka.core.matrix.LinearRegression

All Implemented Interfaces:
  `RevisionHandler`

public class LinearRegression extends Object implements RevisionHandler
Class for performing (ridged) linear regression using Tikhonov regularization.

Version:
  $Revision: 9768 $
Author:
  Fracpete (fracpete at waikato dot ac dot nz)

## Constructor Summary

Constructors
Constructor
Description
`LinearRegression(Matrix a, Matrix y, double ridge)`
Performs a (ridged) linear regression.
`LinearRegression(Matrix a, Matrix y, double[] w, double ridge)`
Performs a weighted (ridged) linear regression.

## Method Summary

Modifier and Type
Method
Description
`final double[]`
`getCoefficients()`
returns the calculated coefficients
`String`
`getRevision()`
Returns the revision string.
`String`
`toString()`
returns the coefficients in a string representation

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### LinearRegression

public LinearRegression(Matrix a, Matrix y, double ridge)
Performs a (ridged) linear regression.

Parameters:
  `a` - the matrix to perform the regression on
  `y` - the dependent variable vector
  `ridge` - the ridge parameter
Throws:
  `IllegalArgumentException` - if not successful

### LinearRegression

public LinearRegression(Matrix a, Matrix y, double[] w, double ridge)
Performs a weighted (ridged) linear regression.

Parameters:
  `a` - the matrix to perform the regression on
  `y` - the dependent variable vector
  `w` - the array of data point weights
  `ridge` - the ridge parameter
Throws:
  `IllegalArgumentException` - if the wrong number of weights were provided.

## Method Details

### getCoefficients

public final double[] getCoefficients()
returns the calculated coefficients

Returns:
  the coefficients

### toString

public String toString()
returns the coefficients in a string representation

Overrides:
  `toString` in class `Object`

### getRevision

public String getRevision()
Returns the revision string.

Specified by:
  `getRevision` in interface `RevisionHandler`
Returns:
  the revision