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-06-16 21:56:15 +00:00
|
|
|
protected $targets = [];
|
2016-04-07 20:12:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $samples
|
2016-06-16 21:56:15 +00:00
|
|
|
* @param array $targets
|
2016-04-07 20:13:31 +00:00
|
|
|
*
|
|
|
|
* @throws InvalidArgumentException
|
2016-04-07 20:12:36 +00:00
|
|
|
*/
|
2016-06-16 21:56:15 +00:00
|
|
|
public function __construct(array $samples, array $targets)
|
2016-04-07 20:12:36 +00:00
|
|
|
{
|
2016-06-16 21:56:15 +00:00
|
|
|
if (count($samples) != count($targets)) {
|
2016-04-18 20:58:43 +00:00
|
|
|
throw InvalidArgumentException::arraySizeNotMatch();
|
2016-04-07 20:13:31 +00:00
|
|
|
}
|
|
|
|
|
2016-04-07 20:12:36 +00:00
|
|
|
$this->samples = $samples;
|
2016-06-16 21:56:15 +00:00
|
|
|
$this->targets = $targets;
|
2016-04-07 20:12:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getSamples(): array
|
|
|
|
{
|
|
|
|
return $this->samples;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2016-06-16 21:56:15 +00:00
|
|
|
public function getTargets(): array
|
2016-04-07 20:12:36 +00:00
|
|
|
{
|
2016-06-16 21:56:15 +00:00
|
|
|
return $this->targets;
|
2016-04-07 20:12:36 +00:00
|
|
|
}
|
|
|
|
}
|