mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2025-04-04 17:21:53 +00:00
add distanceMetric for dbscan
This commit is contained in:
parent
22963114c3
commit
26be771668
@ -4,6 +4,7 @@ declare(strict_types = 1);
|
|||||||
namespace Phpml\Clustering;
|
namespace Phpml\Clustering;
|
||||||
|
|
||||||
use Phpml\Math\Distance;
|
use Phpml\Math\Distance;
|
||||||
|
use Phpml\Math\Distance\Euclidean;
|
||||||
|
|
||||||
class DBSCAN implements Clusterer
|
class DBSCAN implements Clusterer
|
||||||
{
|
{
|
||||||
@ -25,12 +26,17 @@ class DBSCAN implements Clusterer
|
|||||||
/**
|
/**
|
||||||
* @param float $epsilon
|
* @param float $epsilon
|
||||||
* @param int $minSamples
|
* @param int $minSamples
|
||||||
|
* @param Distance $distanceMetric
|
||||||
*/
|
*/
|
||||||
public function __construct($epsilon = 0.5, $minSamples = 3)
|
public function __construct($epsilon = 0.5, $minSamples = 3, Distance $distanceMetric = null)
|
||||||
{
|
{
|
||||||
|
if (null === $distanceMetric) {
|
||||||
|
$distanceMetric = new Euclidean();
|
||||||
|
}
|
||||||
|
|
||||||
$this->epsilon = $epsilon;
|
$this->epsilon = $epsilon;
|
||||||
$this->minSamples = $minSamples;
|
$this->minSamples = $minSamples;
|
||||||
$this->distanceMetric = new Distance\Euclidean();
|
$this->distanceMetric = $distanceMetric;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user