PHP Class Phpml\Regression\LeastSquares

Inheritance: implements Regression, use trait Phpml\Helper\Predictable
Exibir arquivo Open project: php-ai/php-ml Class Usage Examples

Public Methods

Method Description
getCoefficients ( ) : array
getIntercept ( ) : float
predictSample ( array $sample ) : mixed
train ( array $samples, array $targets )

Private Methods

Method Description
computeCoefficients ( ) coefficient(b) = (X'X)-1X'Y.
getSamplesMatrix ( ) : Matrix Add one dimension for intercept calculation.
getTargetsMatrix ( ) : Matrix

Method Details

getCoefficients() public method

public getCoefficients ( ) : array
return array

getIntercept() public method

public getIntercept ( ) : float
return float

predictSample() public method

public predictSample ( array $sample ) : mixed
$sample array
return mixed

train() public method

public train ( array $samples, array $targets )
$samples array
$targets array