Skip to content

Commit

Permalink
change interfaces and add Estimator and Pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
akondas committed Jun 16, 2016
1 parent cc50d2c commit cab79e7
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 27 deletions.
16 changes: 3 additions & 13 deletions src/Phpml/Classification/Classifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,8 @@

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 changes: 21 additions & 0 deletions src/Phpml/Estimator.php
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 2 additions & 0 deletions src/Phpml/FeatureExtraction/TfIdfTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Phpml\FeatureExtraction;

use Phpml\Transformer;

class TfIdfTransformer implements Transformer
{
/**
Expand Down
1 change: 1 addition & 0 deletions src/Phpml/FeatureExtraction/TokenCountVectorizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Phpml\FeatureExtraction;

use Phpml\Tokenization\Tokenizer;
use Phpml\Transformer;

class TokenCountVectorizer implements Transformer
{
Expand Down
29 changes: 29 additions & 0 deletions src/Phpml/Pipeline.php
Original file line number Diff line number Diff line change
@@ -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;
}
}
16 changes: 3 additions & 13 deletions src/Phpml/Regression/Regression.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,8 @@

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
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare (strict_types = 1);

namespace Phpml\FeatureExtraction;
namespace Phpml;

interface Transformer
{
Expand Down

0 comments on commit cab79e7

Please sign in to comment.