public function split(float $ratio = 0.5) : array
    {
        if ($ratio <= 0 or $ratio >= 1) {
            throw new InvalidArgumentException('Split ratio must be strictly'
            . " between 0 and 1, $ratio given.");
        }

        $n = (int) ($ratio * $this->numRows());

        $leftSamples = array_slice($this->samples, 0, $n);
        $leftLabels = array_slice($this->labels, 0, $n);

        $rightSamples = array_slice($this->samples, $n);
        $rightLabels = array_slice($this->labels, $n);

        return [
            self::quick($leftSamples, $leftLabels),
            self::quick($rightSamples, $rightLabels),
        ];
    }
public function split(float $ratio = 0.5) : array
    {
        if ($ratio <= 0 or $ratio >= 1) {
            throw new InvalidArgumentException('Split ratio must be strictly'
            . " between 0 and 1, $ratio given.");
        }

        $n = (int) ($ratio * $this->numRows());

        $leftSamples = array_slice($this->samples, 0, $n);
        $leftLabels = array_slice($this->labels, 0, $n);

        $rightSamples = array_slice($this->samples, $n);
        $rightLabels = array_slice($this->labels, $n);

        return [
            self::quick($leftSamples, $leftLabels),
            self::quick($rightSamples, $rightLabels),
        ];
    }
public function split ( float $ ratio = 0.5 ) : array { if ( $ ratio <= 0 or $ ratio >= 1 ) { throw new InvalidArgumentException ( 'Split ratio must be strictly' . " between 0 and 1, $ratio given." ) ; } $ n = ( int ) ( $ ratio * $ this -> numRows ( ) ) ; $ leftSamples = array_slice ( $ this -> samples , 0 , $ n ) ; $ leftLabels = array_slice ( $ this -> labels , 0 , $ n ) ; $ rightSamples = array_slice ( $ this -> samples , $ n ) ; $ rightLabels = array_slice ( $ this -> labels , $ n ) ; return [ self :: quick ( $ leftSamples , $ leftLabels ) , self :: quick ( $ rightSamples , $ rightLabels ) , ] ; }
Split the dataset into two subsets with a given ratio of samples.

@param float $ratio
@throws \InvalidArgumentException
@return self[]
Split the dataset into two subsets with a given ratio of samples .