src/PredictionBuilder.php
public function build() {
        // Check the number of observations in a given dataset
        if ($this->count < 3) {
            throw new \InvalidArgumentException('The dataset should contain a minimum of 3 observations.');
        }
        
        $b = $this->round_($this->bSlope());
        $a = $this->round_($this->aIntercept($b));
        $model = $this->createModel($a, $b);
        $y = $this->round_($model($this->x));
        
        $result = new \stdClass();
        $result->ln_model = (string) ($a.'+'.$b.'x');
        $result->cor = $this->round_($this->corCoefficient($b));
        $result->x = $this->x;
        $result->y = $y;
        
        return $result;
    }
public function build() {
        // Check the number of observations in a given dataset
        if ($this->count < 3) {
            throw new \InvalidArgumentException('The dataset should contain a minimum of 3 observations.');
        }
        
        $b = $this->round_($this->bSlope());
        $a = $this->round_($this->aIntercept($b));
        $model = $this->createModel($a, $b);
        $y = $this->round_($model($this->x));
        
        $result = new \stdClass();
        $result->ln_model = (string) ($a.'+'.$b.'x');
        $result->cor = $this->round_($this->corCoefficient($b));
        $result->x = $this->x;
        $result->y = $y;
        
        return $result;
    }
public function build ( ) { // Check the number of observations in a given dataset if ( $ this -> count < 3 ) { throw new \ InvalidArgumentException ( 'The dataset should contain a minimum of 3 observations.' ) ; } $ b = $ this -> round_ ( $ this -> bSlope ( ) ) ; $ a = $ this -> round_ ( $ this -> aIntercept ( $ b ) ) ; $ model = $ this -> createModel ( $ a , $ b ) ; $ y = $ this -> round_ ( $ model ( $ this -> x ) ) ; $ result = new \ stdClass ( ) ; $ result -> ln_model = ( string ) ( $ a . '+' . $ b . 'x' ) ; $ result -> cor = $ this -> round_ ( $ this -> corCoefficient ( $ b ) ) ; $ result -> x = $ this -> x ; $ result -> y = $ y ; return $ result ; }
Builds a prediction of the expected value of y for a given x, based on a linear regression model.

@return \stdClass

@throws \InvalidArgumentException
Builds a prediction of the expected value of y for a given x based on a linear regression model .