Append this dataset with another dataset.

@param \Rubix\ML\Datasets\Dataset $dataset
@return \Rubix\ML\Datasets\Dataset
194102
public function append(Dataset $dataset) : Dataset
    {
        return self::quick(array_merge($this->samples, $dataset->samples()));
    }
959146
public function train(Dataset $dataset) : void
    {
        DatasetIsCompatibleWithEstimator::check($dataset, $this);

        $this->centroids = $this->seeder->seed($dataset, $this->k);

        $sizes = array_fill(1, $this->k, 0);
        $sizes[0] = $dataset->numRows();

        $this->sizes = $sizes;

        $this->steps = [];

        $this->partial($dataset);
    }
733329
public function update(Dataset $dataset) : void
    {
        if (!$dataset->homogeneous() or $dataset->columnType(0) !== DataType::CONTINUOUS) {
            throw new InvalidArgumentException('This transformer only works'
                . ' with continuous features.');
        }

        if ($this->dfs === null or $this->n === null) {
            $this->fit($dataset);
            
            return;
        }

        foreach ($dataset as $sample) {
            foreach ($sample as $column => $feature) {
                if ($feature > 0) {
                    $this->dfs[$column]++;
                }
            }
        }

        $this->n += $dataset->numRows();

        $idfs = [];

        foreach ($this->dfs as $df) {
            $idfs[] = log($this->n / $df) + 1.;
        }

        $this->idfs = $idfs;
    }
28533
public static function createMany(array $datasets) : array
    {
        $models = [];

        foreach ($datasets as $dataset) {
            $models[] = static::create($dataset);
        }

        return $models;
    }
135859
public function bind($dataset)
    {
        if ($dataset === null) {
            return $this;
        }

        if ($dataset instanceof \Traversable) {
            $dataset = iterator_to_array($dataset);
        } elseif (is_object($dataset)) {
            $dataset = [$dataset];
        } elseif (!is_array($dataset)) {
            throw new \InvalidArgumentException('Need an array or object');
        }

        foreach ($dataset as $k => $data) {
            $this[$k] = $data;
        }

        return $this;
    }
523674
protected function loadConfig($dataset)
    {
        $config_file = $this->getDatasets($dataset);
        $config = include $config_file;
        $this->checkConfig($config);

        return $config;
    }
1340728
public function formatParams(Dataset $dataset)
    {
        $paramDefinition = $this->getParamDefinition();
        foreach ($dataset as $key => $value) {
            $value = trim($value);
            is_numeric($value) && settype($value, 'string');

            if (isset($paramDefinition[$key])) {
                if ($this->getParamValueLength($value) > $paramDefinition[$key]['length']) {
                    $value = substr($value, 0, $paramDefinition[$key]['length']);
                }
            }

            if (isset($paramDefinition[$key]['mb_str_pad'])) {
                $value = StringHelper::mbStringPad(
                    $value,
                    $paramDefinition[$key]['length'],
                    isset($paramDefinition[$key]['padChar']) ? $paramDefinition[$key]['padChar'] : ' ',
                    $paramDefinition[$key]['pad'],
                    $this->getCharset()
                );
            } elseif (isset($paramDefinition[$key]['format'])) {
                $value = sprintf($paramDefinition[$key]['format'], $value);
            }

            if ($this->getCharset() !== self::DEFAULT_CHARSET) {
                $value = iconv(self::DEFAULT_CHARSET, $this->getCharset() . '//TRANSLIT', $value);
            }

            $dataset->offsetSet($key, $value);

            // remove empty values
            if (!isset($value)) {
                $dataset->offsetUnset($key);
            }
        }
    }
719504
public static function terminate(Labeled $dataset) : self
    {
        $samples = $dataset->samples();
        $labels = $dataset->labels();

        $min = $max = [];

        foreach ($dataset->columns() as $values) {
            $min[] = min($values);
            $max[] = max($values);
        }

        return new self($samples, $labels, $min, $max);
    }
1209964
public function fit(Dataset $dataset) : void
    {
        $this->strategies = [];

        foreach ($dataset->types() as $column => $type) {
            $values = [];

            foreach ($dataset->column($column) as $value) {
                if ($value !== $this->placeholder) {
                    $values[] = $value;
                }
            }

            switch ($type) {
                case DataType::CATEGORICAL:
                    $strategy = clone $this->categorical;
                    break 1;

                case DataType::CONTINUOUS:
                    $strategy = clone $this->continuous;
                    break 1;

                default:
                    throw new InvalidArgumentException('This transformer'
                        . ' only handles categorical and continuous'
                        . ' features, ' . DataType::TYPES[$type]
                        . ' found.');
            }

            $strategy->fit($values);

            $this->strategies[$column] = $strategy;
        }
    }
626779
public function train(Dataset $dataset) : void
    {
        DatasetIsCompatibleWithEstimator::check($dataset, $this);

        [$m, $n] = $dataset->shape();

        $this->r = Matrix::gaussian($n, $this->estimators);

        if ($n >= self::MIN_SPARSE_DIMENSIONS) {
            $mask = Matrix::rand($n, $this->estimators)
                ->less(sqrt($n) / $n);

            $this->r = $this->r->multiply($mask);
        }

        $z = Matrix::quick($dataset->samples())
            ->matmul($this->r)
            ->transpose();

        foreach ($z as $values) {
            $min = min($values) - EPSILON;
            $max = max($values) + EPSILON;

            $edges = Vector::linspace($min, $max, $this->bins + 1)->asArray();

            $edges[] = INF;

            $counts = array_fill(0, $this->bins + 2, 0);

            $interior = array_slice($edges, 1, $this->bins);

            foreach ($values as $value) {
                foreach ($interior as $k => $edge) {
                    if ($value < $edge) {
                        $counts[$k]++;

                        continue 2;
                    }
                }

                $counts[$this->bins]++;
            }

            $densities = [];

            foreach ($counts as $count) {
                $densities[] = $count > 0
                    ? -log($count / $m)
                    : -LOG_EPSILON;
            }

            $this->histograms[] = [$edges, $counts, $densities];
        }

        $this->n = $m;
    }
632622
public function predict(Dataset $dataset) : array
    {
        $this->preprocess($dataset);

        return $this->estimator->predict($dataset);
    }
60704
public function saveDataset($key, $dataset)
    {
        $data = $this->session->get(self::KEY);
        $data[$key] = $dataset;
        $this->session->set(self::KEY, $data);
        return $this;
    }
483453
def append(self, dataset, identifier):
        

        dataset = dataset if isinstance(dataset, MLDataset) else MLDataset(dataset)

        if not self._is_init:
            self._ids = set(dataset.keys)
            self._classes = dataset.classes
            self._class_sizes = dataset.class_sizes

            self._num_samples = len(self._ids)
            self._modalities[identifier] = dataset.data
            self._num_features.append(dataset.num_features)

            # maintaining a no-data MLDataset internally for reuse its methods
            self._dataset = copy(dataset)
            # replacing its data with zeros
            self._dataset.data = {id_: np.zeros(1) for id_ in self._ids}

            self._is_init = True
        else:
            # this also checks for the size (num_samples)
            if set(dataset.keys) != self._ids:
                raise ValueError('Differing set of IDs in two datasets.'
                                 'Unable to add this dataset to the MultiDataset.')

            if dataset.classes != self._classes:
                raise ValueError('Classes for IDs differ in the two datasets.')

            if identifier not in self._modalities:
                self._modalities[identifier] = dataset.data
                self._num_features.append(dataset.num_features)
            else:
                raise KeyError('{} already exists in MultiDataset'.format(identifier))

        # each addition should be counted, if successful
        self._modality_count += 1
95279
private function getMacSource(Dataset $dataset)
    {
        $macParams = $this->getNormalizedMacParams($dataset, $dataset->getParam('VK_SERVICE'));
        $source = '';

        foreach ($macParams as $value) {
            $length = $this->getParamValueLength($value);
            $source .= str_pad($length, 3, '0', STR_PAD_LEFT) . $value;
        }

        return $source;
    }
1310688
public function execute(DataSetInterface $dataSet): void
    {
        $this->assertHaveProductMeasurementSalesUnit($dataSet[ProductPackagingUnitDataSetInterface::COLUMN_CONCRETE_SKU]);
        $dataSet = $this->normalizeDataSet($dataSet);
        $productPackagingUnitTypeId = $this->getIdProductPackagingUnitTypeByName($dataSet[ProductPackagingUnitDataSetInterface::COLUMN_TYPE_NAME]);
        $productConcreteId = $this->getIdProductBySku($dataSet[ProductPackagingUnitDataSetInterface::COLUMN_CONCRETE_SKU]);

        $productPackagingUnitEntity = $this->getProductPackagingUnitQuery()
            ->filterByFkProduct($productConcreteId)
            ->findOneOrCreate();

        $this->persistLeadProduct($dataSet, $productConcreteId);

        $productPackagingUnitEntity
            ->setHasLeadProduct($dataSet[ProductPackagingUnitDataSetInterface::COLUMN_HAS_LEAD_PRODUCT])
            ->setFkProductPackagingUnitType($productPackagingUnitTypeId);

        $productPackagingUnitEntity->save();

        if ($this->hasAmount($dataSet)) {
            $this->persistAmount($dataSet, $productPackagingUnitEntity);
        }

        $this->addPublishEvents(ProductPackagingUnitEvents::PRODUCT_ABSTRACT_PACKAGING_PUBLISH, $this->getIdProductAbstractByProductSku($dataSet[ProductPackagingUnitDataSetInterface::COLUMN_CONCRETE_SKU]));
    }
1006364
public static function toNQuads($dataset) {
    $quads = array();
    foreach($dataset as $graph_name => $triples) {
      foreach($triples as $triple) {
        if($graph_name === '@default') {
          $graph_name = null;
        }
        $quads[] = self::toNQuad($triple, $graph_name);
      }
    }
    sort($quads);
    return implode($quads);
  }
1334506
public function train(Dataset $dataset) : void
    {
        if (!$dataset instanceof Labeled) {
            throw new InvalidArgumentException('This estimator requires a'
                . ' labeled training set.');
        }

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

        $k = $dataset->numColumns();

        $this->columns = range(0, $dataset->numColumns() - 1);
        $this->maxFeatures = $this->maxFeatures ?? (int) round(sqrt($k));

        $this->grow($dataset);

        $this->columns = [];
    }