change interfaces and add Estimator and Pipeline

This commit is contained in:
Arkadiusz Kondas 2016-06-16 09:00:10 +02:00
parent cc50d2c9b1
commit cab79e7e36
7 changed files with 60 additions and 27 deletions

View File

@ -4,18 +4,8 @@ declare (strict_types = 1);
namespace Phpml\Classification;
interface Classifier
{
/**
* @param array $samples
* @param array $labels
*/
public function train(array $samples, array $labels);
use Phpml\Estimator;
/**
* @param array $samples
*
* @return mixed
*/
public function predict(array $samples);
interface Classifier extends Estimator
{
}

21
src/Phpml/Estimator.php Normal file
View File

@ -0,0 +1,21 @@
<?php
declare (strict_types = 1);
namespace Phpml;
interface Estimator
{
/**
* @param array $samples
* @param array $targets
*/
public function train(array $samples, array $targets);
/**
* @param array $samples
*
* @return mixed
*/
public function predict(array $samples);
}

View File

@ -4,6 +4,8 @@ declare (strict_types = 1);
namespace Phpml\FeatureExtraction;
use Phpml\Transformer;
class TfIdfTransformer implements Transformer
{
/**

View File

@ -5,6 +5,7 @@ declare (strict_types = 1);
namespace Phpml\FeatureExtraction;
use Phpml\Tokenization\Tokenizer;
use Phpml\Transformer;
class TokenCountVectorizer implements Transformer
{

29
src/Phpml/Pipeline.php Normal file
View File

@ -0,0 +1,29 @@
<?php
declare (strict_types = 1);
namespace Phpml\Pipeline;
class Pipeline
{
/**
* @var array
*/
private $stages;
/**
* @param array $stages
*/
public function __construct(array $stages)
{
$this->stages = $stages;
}
/**
* @param mixed $stage
*/
public function addStage($stage)
{
$this->stages[] = $stage;
}
}

View File

@ -4,18 +4,8 @@ declare (strict_types = 1);
namespace Phpml\Regression;
interface Regression
{
/**
* @param array $samples
* @param array $targets
*/
public function train(array $samples, array $targets);
use Phpml\Estimator;
/**
* @param array $samples
*
* @return mixed
*/
public function predict(array $samples);
interface Regression extends Estimator
{
}

View File

@ -2,7 +2,7 @@
declare (strict_types = 1);
namespace Phpml\FeatureExtraction;
namespace Phpml;
interface Transformer
{