mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-29 16:24:05 +00:00
change interfaces and add Estimator and Pipeline
This commit is contained in:
parent
cc50d2c9b1
commit
cab79e7e36
@ -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
21
src/Phpml/Estimator.php
Normal 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);
|
||||
}
|
@ -4,6 +4,8 @@ declare (strict_types = 1);
|
||||
|
||||
namespace Phpml\FeatureExtraction;
|
||||
|
||||
use Phpml\Transformer;
|
||||
|
||||
class TfIdfTransformer implements Transformer
|
||||
{
|
||||
/**
|
||||
|
@ -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
29
src/Phpml/Pipeline.php
Normal 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;
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace Phpml\FeatureExtraction;
|
||||
namespace Phpml;
|
||||
|
||||
interface Transformer
|
||||
{
|
Loading…
Reference in New Issue
Block a user