Get list of dataset's paths, or a specific dataset's path.

@param bool $dataset

@return array|string

@SuppressWarnings(PHPMD.BooleanArgumentFlag)
@SuppressWarnings(PHPMD.ExitExpression)
@SuppressWarnings(PHPMD.CognitiveComplexity)
778881
protected function getDatasets($dataset = false)
    {
        $source_packages = config('datasets.source', []);

        $result = [];

        foreach ($source_packages as $folder) {

            // Get folder contents of datasets
            $datasets = new Filesystem(new Adapter(base_path('vendor/'.$folder.'/datasets/')));

            try {
                $files = $datasets->listContents();
            } catch (\Exception $exception) {
            }

            foreach ($files as $file) {
                $result[$file['filename']] = base_path('vendor/'.$folder.'/datasets/'.$file['basename']);
            }
        }

        if ($dataset !== false) {
            if (!isset($result[$dataset])) {
                $this->error(sprintf("Requested dataset '%s' could not be found.", $dataset));

                exit(1);
            }

            // Supplied dataset config file does not exist.
            if (!file_exists($result[$dataset])) {
                $this->error(sprintf('\'%s\' dataset does not exist.', $this->argument('dataset')));
                $this->line('');

                exit(1);
            }

            return $result[$dataset];
        }

        return $result;
    }
632622
public function predict(Dataset $dataset) : array
    {
        $this->preprocess($dataset);

        return $this->estimator->predict($dataset);
    }
525560
protected function buildCacheIndex(DataSetInterface $dataSet): string
    {
        return implode('-', [
            $dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_STORE],
            $dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_CURRENCY],
            $dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_PRICE_PRODUCT],
            $dataSet[PriceProductMerchantRelationshipDataSetInterface::PRICE_NET],
            $dataSet[PriceProductMerchantRelationshipDataSetInterface::PRICE_GROSS],
        ]);
    }
253570
protected function processDataSet(DataSet $dataSet)
    {
        if ($dataSet->getPattern() === File::HEADER_PATTERN) {
            $this->processHeader($dataSet);
        } else {
            $this->processBrowserData($dataSet);
        }
    }
1220837
public function getPaths($source)
    {
        $source = $this->cleanSource($source);
        list(, $paths) = $this->parse($source);

        return $paths;
    }
852703
public function postItem(string $dataset) : array
    {
        try {
            $entry = $this->di->get("request")->getBodyAsJson();
        } catch (\Anax\Request\Exception $e) {
            return [
                ["message" => "500. HTTP request body is not an object/array or valid JSON."],
                500
            ];
        }

        $item = $this->di->get("remserver")->addItem($dataset, $entry);
        return [$item];
    }
1078749
protected function split(Labeled $dataset) : Decision
    {
        $bestVariance = INF;
        $bestColumn = $bestValue = null;
        $bestGroups = [];

        shuffle($this->columns);

        foreach (array_slice($this->columns, 0, $this->maxFeatures) as $column) {
            $values = array_unique($dataset->column($column));

            foreach ($values as $value) {
                $groups = $dataset->partition($column, $value);

                $variance = $this->splitImpurity($groups);

                if ($variance < $bestVariance) {
                    $bestColumn = $column;
                    $bestValue = $value;
                    $bestGroups = $groups;
                    $bestVariance = $variance;
                }

                if ($variance <= $this->tolerance) {
                    break 2;
                }
            }
        }

        return new Decision($bestColumn, $bestValue, $bestGroups, $bestVariance);
    }
321468
def _get_path(dataset_name):
  """"""
  path = _checksum_paths().get(dataset_name, None)
  if path:
    return path
  msg = ('No checksums file could be find for dataset %s. Please create one in '
         'one of: %s') % (dataset_name, ', '.join(_CHECKSUM_DIRS))
  raise AssertionError(msg)
612327
private function addMacSignature(Dataset $dataset)
    {
        $macSource = $this->getMacSource($dataset, 'payment');
        $keyPath = $this->getPkcKeyPath();

        $signature = $this->signWithPrivateKey($keyPath, $macSource);

        $mac = bin2hex($signature);
        $dataset->setParam('mac', $mac);

        // Yes, the ID value in the form and the value in MAC are different
        $dataset->setParam('id', trim($dataset->getParam('id')));
        $dataset->setParam('feedBackUrl', trim($this->getReturnUrl()));
    }
500545
public function proba(Dataset $dataset) : array
    {
        if (!$this->network or !$this->classes) {
            throw new RuntimeException('The learner has not'
                . ' been trained.');
        }

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

        $xT = Matrix::quick($dataset->samples())->transpose();

        $yT = $this->network->infer($xT)->transpose();

        $probabilities = [];

        foreach ($yT as $activations) {
            $probabilities[] = array_combine($this->classes, $activations);
        }

        return $probabilities;
    }
794969
public function getItem(string $dataset, int $itemId) : array
    {
        $item = $this->di->get("remserver")->getItem($dataset, $itemId);
        if (!$item) {
            return [["message" => "The item is not found."]];
        }
        return [$item];
    }
173074
protected function getIdPriceProductStoreEntity(DataSetInterface $dataSet): string
    {
        $cacheIndex = $this->buildCacheIndex($dataSet);
        if (isset($this->idPriceProductStoreCache[$cacheIndex])) {
            return $this->idPriceProductStoreCache[$cacheIndex];
        }

        $priceProductStoreEntity = SpyPriceProductStoreQuery::create()
            ->filterByFkStore($dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_STORE])
            ->filterByFkCurrency($dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_CURRENCY])
            ->filterByFkPriceProduct($dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_PRICE_PRODUCT])
            ->filterByNetPrice((int)$dataSet[PriceProductMerchantRelationshipDataSetInterface::PRICE_NET])
            ->filterByGrossPrice((int)$dataSet[PriceProductMerchantRelationshipDataSetInterface::PRICE_GROSS])
            ->findOneOrCreate();

        $priceProductStoreEntity->save();

        $this->idPriceProductStoreCache[$cacheIndex] = $priceProductStoreEntity->getIdPriceProductStore();

        return $this->idPriceProductStoreCache[$cacheIndex];
    }
1164287
public function proba(Dataset $dataset) : array
    {
        if (empty($this->priors)) {
            throw new RuntimeException('Estimator has not been trained.');
        }

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

        $probabilities = [];

        foreach ($dataset as $sample) {
            $jll = $this->jointLogLikelihood($sample);

            $total = logsumexp($jll);

            $dist = [];

            foreach ($jll as $cluster => $likelihood) {
                $dist[$cluster] = exp($likelihood - $total);
            }

            $probabilities[] = $dist;
        }

        return $probabilities;
    }
704088
public static function datasetName($project, $location, $dataset)
    {
        return self::getDatasetNameTemplate()->render([
            'project' => $project,
            'location' => $location,
            'dataset' => $dataset,
        ]);
    }
741987
public function create($dataset)
    {
        // Event
        $this->triggerEvent(
            'onBefore' . ucfirst(__FUNCTION__),
            [
                'dataset' => &$dataset,
            ]
        );

        if (!($dataset instanceof \Traversable) && !is_array($dataset)) {
            throw new \InvalidArgumentException('DataSet object should be instance of a Traversable');
        }

        $result = $this->doCreate($dataset);

        // Event
        $this->triggerEvent(
            'onAfter' . ucfirst(__FUNCTION__),
            [
                'result' => &$result,
            ]
        );

        return $result;
    }
1030921
public function saveAll($dataSet, $replace = true)
    {
        $result = [];

        $db = $this->db(false);
        $db->startTrans();

        try {
            $pk = $this->getPk();

            if (is_string($pk) && $replace) {
                $auto = true;
            }

            foreach ($dataSet as $key => $data) {
                if (!empty($auto) && isset($data[$pk])) {
                    $result[$key] = self::update($data, [], $this->field);
                } else {
                    $result[$key] = self::create($data, $this->field, $this->replace);
                }
            }

            $db->commit();

            return $this->toCollection($result);
        } catch (\Exception $e) {
            $db->rollback();
            throw $e;
        }
    }
221644
def datasets_directory(path)
      Dataset::Resolver.default = Dataset::DirectoryResolver.new(path)
      Dataset::ContextClassMethods.datasets_database_dump_path = File.join(path, '/tmp/dataset')
    end