public function train(Dataset $dataset) : void
    {
        if ($this->type() === self::CLASSIFIER or $this->type() === self::REGRESSOR) {
            if (!$dataset instanceof Labeled) {
                throw new InvalidArgumentException('This estimator requires a'
                    . ' labeled training set.');
            }
        }

        DatasetIsCompatibleWithEstimator::check($dataset, $this);

        $p = (int) round($this->ratio * $dataset->numRows());

        $this->ensemble = [];

        Loop::run(function () use ($dataset, $p) {
            $pool = new DefaultPool($this->workers);

            $coroutines = [];

            for ($i = 0; $i < $this->estimators; $i++) {
                $estimator = clone $this->base;

                $subset = $dataset->randomSubsetWithReplacement($p);

                $task = new CallableTask(
                    [$this, '_train'],
                    [$estimator, $subset]
                );

                $coroutines[] = call(function () use ($pool, $task) {
                    return yield $pool->enqueue($task);
                });
            }

            $this->ensemble = yield all($coroutines);
            
            return yield $pool->shutdown();
        });
    }
public function train(Dataset $dataset) : void
    {
        if ($this->type() === self::CLASSIFIER or $this->type() === self::REGRESSOR) {
            if (!$dataset instanceof Labeled) {
                throw new InvalidArgumentException('This estimator requires a'
                    . ' labeled training set.');
            }
        }

        DatasetIsCompatibleWithEstimator::check($dataset, $this);

        $p = (int) round($this->ratio * $dataset->numRows());

        $this->ensemble = [];

        Loop::run(function () use ($dataset, $p) {
            $pool = new DefaultPool($this->workers);

            $coroutines = [];

            for ($i = 0; $i < $this->estimators; $i++) {
                $estimator = clone $this->base;

                $subset = $dataset->randomSubsetWithReplacement($p);

                $task = new CallableTask(
                    [$this, '_train'],
                    [$estimator, $subset]
                );

                $coroutines[] = call(function () use ($pool, $task) {
                    return yield $pool->enqueue($task);
                });
            }

            $this->ensemble = yield all($coroutines);
            
            return yield $pool->shutdown();
        });
    }
public function train ( Dataset $ dataset ) : void { if ( $ this -> type ( ) === self :: CLASSIFIER or $ this -> type ( ) === self :: REGRESSOR ) { if ( ! $ dataset instanceof Labeled ) { throw new InvalidArgumentException ( 'This estimator requires a' . ' labeled training set.' ) ; } } DatasetIsCompatibleWithEstimator :: check ( $ dataset , $ this ) ; $ p = ( int ) round ( $ this -> ratio * $ dataset -> numRows ( ) ) ; $ this -> ensemble = [ ] ; Loop :: run ( function ( ) use ( $ dataset , $ p ) { $ pool = new DefaultPool ( $ this -> workers ) ; $ coroutines = [ ] ; for ( $ i = 0 ; $ i < $ this -> estimators ; $ i ++ ) { $ estimator = clone $ this -> base ; $ subset = $ dataset -> randomSubsetWithReplacement ( $ p ) ; $ task = new CallableTask ( [ $ this , '_train' ] , [ $ estimator , $ subset ] ) ; $ coroutines [ ] = call ( function ( ) use ( $ pool , $ task ) { return yield $ pool -> enqueue ( $ task ) ; } ) ; } $ this -> ensemble = yield all ( $ coroutines ) ; return yield $ pool -> shutdown ( ) ; } ) ; }
Instantiate and train each base estimator in the ensemble on a bootstrap
training set.

@param \Rubix\ML\Datasets\Dataset $dataset
@throws \InvalidArgumentException
Instantiate and train each base estimator in the ensemble on a bootstrap training set .