mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-04 20:47:53 +00:00
extract Math namespace
This commit is contained in:
parent
6024b1f664
commit
9330785a6f
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace Phpml\Metric;
|
||||
namespace Phpml\Math;
|
||||
|
||||
interface Distance
|
||||
{
|
@ -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
|
||||
{
|
@ -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
|
||||
{
|
@ -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
|
||||
{
|
@ -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
|
||||
{
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
@ -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
|
||||
{
|
@ -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
|
||||
{
|
@ -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
|
||||
{
|
Loading…
Reference in New Issue
Block a user