php-ml/src/Phpml/Dataset/ArrayDataset.php

44 lines
774 B
PHP
Raw Normal View History

2016-04-07 20:12:36 +00:00
<?php
2016-04-07 20:35:49 +00:00
2016-11-20 21:53:17 +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
/**
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)) {
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
}
public function getSamples() : array
2016-04-07 20:12:36 +00:00
{
return $this->samples;
}
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
}
}