php-ml/tests/Phpml/Dataset/CsvDatasetTest.php

39 lines
981 B
PHP
Raw Normal View History

2016-04-07 20:36:02 +00:00
<?php
2016-11-20 21:53:17 +00:00
declare(strict_types=1);
2016-04-07 20:36:02 +00:00
namespace tests\Phpml\Dataset;
use Phpml\Dataset\CsvDataset;
class CsvDatasetTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \Phpml\Exception\DatasetException
*/
public function testThrowExceptionOnMissingFile()
{
new CsvDataset('missingFile', 3);
}
2016-04-16 19:24:40 +00:00
public function testSampleCsvDatasetWithHeaderRow()
2016-04-07 20:36:02 +00:00
{
$filePath = dirname(__FILE__).'/Resources/dataset.csv';
$dataset = new CsvDataset($filePath, 2, true);
$this->assertEquals(10, count($dataset->getSamples()));
2016-06-16 21:56:15 +00:00
$this->assertEquals(10, count($dataset->getTargets()));
2016-04-07 20:36:02 +00:00
}
2016-04-16 19:24:40 +00:00
public function testSampleCsvDatasetWithoutHeaderRow()
{
$filePath = dirname(__FILE__).'/Resources/dataset.csv';
$dataset = new CsvDataset($filePath, 2, false);
$this->assertEquals(11, count($dataset->getSamples()));
2016-06-16 21:56:15 +00:00
$this->assertEquals(11, count($dataset->getTargets()));
2016-04-16 19:24:40 +00:00
}
2016-04-07 20:36:02 +00:00
}