mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-16 02:07:08 +00:00
a348111e97
* tests: update to PHPUnit 6.0 with rector * fix namespaces on tests * composer + tests: use standard test namespace naming * update travis * resolve conflict * phpstan lvl 2 * phpstan lvl 3 * phpstan lvl 4 * phpstan lvl 5 * phpstan lvl 6 * phpstan lvl 7 * level max * resolve conflict * [cs] clean empty docs * composer: bump to PHPUnit 6.4 * cleanup * composer + travis: add phpstan * phpstan lvl 1 * composer: update dev deps * phpstan fixes * update Contributing with new tools * docs: link fixes, PHP version update * composer: drop php-cs-fixer, cs already handled by ecs * ecs: add old set rules * [cs] apply rest of rules
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Phpml\Tests\Dataset;
|
|
|
|
use Phpml\Dataset\CsvDataset;
|
|
use Phpml\Exception\FileException;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class CsvDatasetTest extends TestCase
|
|
{
|
|
public function testThrowExceptionOnMissingFile(): void
|
|
{
|
|
$this->expectException(FileException::class);
|
|
new CsvDataset('missingFile', 3);
|
|
}
|
|
|
|
public function testSampleCsvDatasetWithHeaderRow(): void
|
|
{
|
|
$filePath = dirname(__FILE__).'/Resources/dataset.csv';
|
|
|
|
$dataset = new CsvDataset($filePath, 2, true);
|
|
|
|
$this->assertCount(10, $dataset->getSamples());
|
|
$this->assertCount(10, $dataset->getTargets());
|
|
}
|
|
|
|
public function testSampleCsvDatasetWithoutHeaderRow(): void
|
|
{
|
|
$filePath = dirname(__FILE__).'/Resources/dataset.csv';
|
|
|
|
$dataset = new CsvDataset($filePath, 2, false);
|
|
|
|
$this->assertCount(11, $dataset->getSamples());
|
|
$this->assertCount(11, $dataset->getTargets());
|
|
}
|
|
|
|
public function testLongCsvDataset(): void
|
|
{
|
|
$filePath = dirname(__FILE__).'/Resources/longdataset.csv';
|
|
|
|
$dataset = new CsvDataset($filePath, 1000, false);
|
|
|
|
$this->assertCount(1000, $dataset->getSamples()[0]);
|
|
$this->assertEquals('label', $dataset->getTargets()[0]);
|
|
}
|
|
}
|