DBSCAN クラスタリング
It is a density-based clustering algorithm: given a set of points in some space, it groups together points that are closely packed together (points with many nearby neighbors), marking as outliers points that lie alone in low-density regions (whose nearest neighbors are too far away). DBSCAN は最も一般的なクラスタリング アルゴリズムで、科学文献で最も引用されるものでもあります。(source: wikipedia)
コンストラクタのパラメータ
- $epsilon - エプシロン、二つの標本が同じ近傍にあると見なされる最大の距離
- $minSamples - 点が中心と見なされる近傍内での標本の数(中心は点自身を含みます)
- $distanceMetric - 距離オブジェクト、デフォルトはユークリッド (distance documentationを見てください)
$dbscan = new DBSCAN($epsilon = 2, $minSamples = 3);
$dbscan = new DBSCAN($epsilon = 2, $minSamples = 3, new Minkowski($lambda=4));
クラスタリング
標本をクラスタに分割するには、単純にcluster
メソッドを使ってください。中に標本を持つクラスタの配列
を返します。
$samples = [[1, 1], [8, 7], [1, 2], [7, 8], [2, 1], [8, 9]];
$dbscan = new DBSCAN($epsilon = 2, $minSamples = 3);
$dbscan->cluster($samples);
// return [0=>[[1, 1], ...], 1=>[[8, 7], ...]]