extract Math namespace

This commit is contained in:
Arkadiusz Kondas 2016-04-20 23:56:33 +02:00
parent 6024b1f664
commit 9330785a6f
12 changed files with 51 additions and 16 deletions

View File

@ -6,8 +6,8 @@ namespace Phpml\Classifier;
use Phpml\Classifier\Traits\Predictable;
use Phpml\Classifier\Traits\Trainable;
use Phpml\Metric\Distance;
use Phpml\Metric\Distance\Euclidean;
use Phpml\Math\Distance;
use Phpml\Math\Distance\Euclidean;
class KNearestNeighbors implements Classifier
{

View File

@ -11,6 +11,41 @@ class SupportVectorMachine implements Classifier
{
use Trainable, Predictable;
/**
* @var float
*/
private $gamma;
/**
* @var float
*/
private $epsilon;
/**
* @var float
*/
private $tolerance;
/**
* @var int
*/
private $upperBound;
/**
* @param float $gamma
* @param float $epsilon
* @param float $tolerance
* @param int $upperBound
*/
public function __construct(float $gamma = .5, float $epsilon = .001, float $tolerance = .001, int $upperBound = 100)
{
$this->gamma = $gamma;
$this->epsilon = $epsilon;
$this->tolerance = $tolerance;
$this->upperBound = $upperBound;
}
/**
* @param array $sample
*

View File

@ -2,7 +2,7 @@
declare (strict_types = 1);
namespace Phpml\Metric;
namespace Phpml\Math;
interface Distance
{

View File

@ -2,10 +2,10 @@
declare (strict_types = 1);
namespace Phpml\Metric\Distance;
namespace Phpml\Math\Distance;
use Phpml\Exception\InvalidArgumentException;
use Phpml\Metric\Distance;
use Phpml\Math\Distance;
class Chebyshev implements Distance
{

View File

@ -2,10 +2,10 @@
declare (strict_types = 1);
namespace Phpml\Metric\Distance;
namespace Phpml\Math\Distance;
use Phpml\Exception\InvalidArgumentException;
use Phpml\Metric\Distance;
use Phpml\Math\Distance;
class Euclidean implements Distance
{

View File

@ -2,10 +2,10 @@
declare (strict_types = 1);
namespace Phpml\Metric\Distance;
namespace Phpml\Math\Distance;
use Phpml\Exception\InvalidArgumentException;
use Phpml\Metric\Distance;
use Phpml\Math\Distance;
class Manhattan implements Distance
{

View File

@ -2,10 +2,10 @@
declare (strict_types = 1);
namespace Phpml\Metric\Distance;
namespace Phpml\Math\Distance;
use Phpml\Exception\InvalidArgumentException;
use Phpml\Metric\Distance;
use Phpml\Math\Distance;
class Minkowski implements Distance
{

View File

@ -5,7 +5,7 @@ declare (strict_types = 1);
namespace tests\Classifier;
use Phpml\Classifier\KNearestNeighbors;
use Phpml\Metric\Distance\Chebyshev;
use Phpml\Math\Distance\Chebyshev;
class KNearestNeighborsTest extends \PHPUnit_Framework_TestCase
{

View File

@ -4,7 +4,7 @@ declare (strict_types = 1);
namespace tests\Phpml\Metric;
use Phpml\Metric\Distance\Chebyshev;
use Phpml\Math\Distance\Chebyshev;
class ChebyshevTest extends \PHPUnit_Framework_TestCase
{

View File

@ -4,7 +4,7 @@ declare (strict_types = 1);
namespace tests\Phpml\Metric;
use Phpml\Metric\Distance\Euclidean;
use Phpml\Math\Distance\Euclidean;
class EuclideanTest extends \PHPUnit_Framework_TestCase
{

View File

@ -4,7 +4,7 @@ declare (strict_types = 1);
namespace tests\Phpml\Metric;
use Phpml\Metric\Distance\Manhattan;
use Phpml\Math\Distance\Manhattan;
class ManhattanTest extends \PHPUnit_Framework_TestCase
{

View File

@ -4,7 +4,7 @@ declare (strict_types = 1);
namespace tests\Phpml\Metric;
use Phpml\Metric\Distance\Minkowski;
use Phpml\Math\Distance\Minkowski;
class MinkowskiTest extends \PHPUnit_Framework_TestCase
{