2016-04-07 20:12:36 +00:00
|
|
|
<?php
|
2016-04-07 20:35:49 +00:00
|
|
|
|
|
|
|
declare (strict_types = 1);
|
2016-04-07 20:12:36 +00:00
|
|
|
|
|
|
|
namespace Phpml\Dataset;
|
|
|
|
|
2016-04-07 20:13:31 +00:00
|
|
|
use Phpml\Exception\InvalidArgumentException;
|
|
|
|
|
2016-04-07 20:12:36 +00:00
|
|
|
class ArrayDataset implements Dataset
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2016-04-07 20:19:04 +00:00
|
|
|
protected $samples = [];
|
2016-04-07 20:12:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2016-04-07 20:19:04 +00:00
|
|
|
protected $labels = [];
|
2016-04-07 20:12:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $samples
|
|
|
|
* @param array $labels
|
2016-04-07 20:13:31 +00:00
|
|
|
*
|
|
|
|
* @throws InvalidArgumentException
|
2016-04-07 20:12:36 +00:00
|
|
|
*/
|
|
|
|
public function __construct(array $samples, array $labels)
|
|
|
|
{
|
2016-04-07 20:13:31 +00:00
|
|
|
if (count($samples) != count($labels)) {
|
|
|
|
throw InvalidArgumentException::sizeNotMatch();
|
|
|
|
}
|
|
|
|
|
2016-04-07 20:12:36 +00:00
|
|
|
$this->samples = $samples;
|
|
|
|
$this->labels = $labels;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getSamples(): array
|
|
|
|
{
|
|
|
|
return $this->samples;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getLabels(): array
|
|
|
|
{
|
|
|
|
return $this->labels;
|
|
|
|
}
|
|
|
|
}
|