Top Description Inners Fields Constructors Methods
org.apache.commons.math3.stat.clustering

public Class DBSCANClusterer<T extends Clusterable<T>>

extends Object
Class Inheritance
Annotations
@Deprecated
Type Parameters
<T>
type of the points to cluster
Imports
java.util.ArrayList, .Collection, .HashMap, .HashSet, .List, .Map, .Set, org.apache.commons.math3.exception.NotPositiveException, .NullArgumentException, org.apache.commons.math3.util.MathUtils

Deprecated

As of 3.2 (to be removed in 4.0), use org.apache.commons.math3.ml.clustering.DBSCANClusterer instead

DBSCAN (density-based spatial clustering of applications with noise) algorithm.

The DBSCAN algorithm forms clusters based on the idea of density connectivity, i.e. a point p is density connected to another point q, if there exists a chain of points pi, with i = 1 .. n and p1 = p and pn = q, such that each pair <pi, pi+1> is directly density-reachable. A point q is directly density-reachable from point p if it is in the ε-neighborhood of this point.

Any point that is not density-reachable from a formed cluster is treated as noise, and will thus not be present in the result.

The algorithm requires two parameters:

Note

as DBSCAN is not a centroid-based clustering algorithm, the resulting Cluster objects will have no defined center, i.e. Cluster#getCenter() will return null.

Since
3.1
See Also
DBSCAN (wikipedia), A Density-Based Algorithm for Discovering Clusters in Large Spatial Databases with Noise

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
DBSCANClusterer.PointStatus

Status of a point during the clustering process.

Field Summary

Modifier and TypeField and Description
private final double
eps

Maximum radius of the neighborhood to be considered.

private final int
minPts

Minimum number of points needed for a cluster.

Constructor Summary

AccessConstructor and Description
public
DBSCANClusterer(final double
maximum radius of the neighborhood to be considered
eps
,
final int
minimum number of points needed for a cluster
minPts
)

Creates a new instance of a DBSCANClusterer.

Method Summary

Modifier and TypeMethod and Description
public List<Cluster<T>>

Returns:

the list of clusters
cluster
(final Collection<T>
the points to cluster
points
)

Performs DBSCAN cluster analysis.

private Cluster<T>

Returns:

the expanded cluster
expandCluster
(final Cluster<T>
Cluster to expand
cluster
,
final T
Point to add to cluster
point
,
final List<T>
List of neighbors
neighbors
,
final Collection<T>
the data set
points
,
final Map<Clusterable<T>, DBSCANClusterer.PointStatus>
the set of already visited points
visited
)
Deprecated as a consequence of Cluster being deprecated.

Expands the cluster to include density-reachable items.

public double

Returns:

maximum radius of the neighborhood
getEps
()

Returns the maximum radius of the neighborhood to be considered.

public int

Returns:

minimum number of points needed for a cluster
getMinPts
()

Returns the minimum number of points needed for a cluster.

private List<T>

Returns:

the List of neighbors
getNeighbors
(final T
the point to look for
point
,
final Collection<T>
possible neighbors
points
)

Returns a list of density-reachable neighbors of a point.

private List<T>

Returns:

merged lists
merge
(final List<T>
first list
one
,
final List<T>
second list
two
)

Merges two lists together.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

epsback to summary
private final double eps

Maximum radius of the neighborhood to be considered.

minPtsback to summary
private final int minPts

Minimum number of points needed for a cluster.

Constructor Detail

DBSCANClustererback to summary
public DBSCANClusterer(final double eps, final int minPts) throws NotPositiveException

Creates a new instance of a DBSCANClusterer.

Parameters
eps:double

maximum radius of the neighborhood to be considered

minPts:int

minimum number of points needed for a cluster

Exceptions
NotPositiveException:
if eps < 0.0 or minPts < 0

Method Detail

clusterback to summary
public List<Cluster<T>> cluster(final Collection<T> points) throws NullArgumentException

Performs DBSCAN cluster analysis.

Note

as DBSCAN is not a centroid-based clustering algorithm, the resulting Cluster objects will have no defined center, i.e. Cluster#getCenter() will return null.

Parameters
points:Collection<T>

the points to cluster

Returns:List<Cluster<T>>

the list of clusters

Exceptions
NullArgumentException:
if the data points are null
expandClusterback to summary
private Cluster<T> expandCluster(final Cluster<T> cluster, final T point, final List<T> neighbors, final Collection<T> points, final Map<Clusterable<T>, DBSCANClusterer.PointStatus> visited)

Deprecated

as a consequence of Cluster being deprecated. See corresponding docs for further information.

Expands the cluster to include density-reachable items.

Parameters
cluster:Cluster<T>

Cluster to expand

point:T

Point to add to cluster

neighbors:List<T>

List of neighbors

points:Collection<T>

the data set

visited:Map<Clusterable<T>, DBSCANClusterer.PointStatus>

the set of already visited points

Returns:Cluster<T>

the expanded cluster

getEpsback to summary
public double getEps()

Returns the maximum radius of the neighborhood to be considered.

Returns:double

maximum radius of the neighborhood

getMinPtsback to summary
public int getMinPts()

Returns the minimum number of points needed for a cluster.

Returns:int

minimum number of points needed for a cluster

getNeighborsback to summary
private List<T> getNeighbors(final T point, final Collection<T> points)

Returns a list of density-reachable neighbors of a point.

Parameters
point:T

the point to look for

points:Collection<T>

possible neighbors

Returns:List<T>

the List of neighbors

mergeback to summary
private List<T> merge(final List<T> one, final List<T> two)

Merges two lists together.

Parameters
one:List<T>

first list

two:List<T>

second list

Returns:List<T>

merged lists

org.apache.commons.math3.stat.clustering back to summary

private final Enum DBSCANClusterer.PointStatus

extends Enum<DBSCANClusterer.PointStatus>
Class Inheritance

Status of a point during the clustering process.

Field Summary

Modifier and TypeField and Description
public static final DBSCANClusterer.PointStatus
NOISE

The point has is considered to be noise.

public static final DBSCANClusterer.PointStatus
PART_OF_CLUSTER

The point is already part of a cluster.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static DBSCANClusterer.PointStatus
public static DBSCANClusterer.PointStatus[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

NOISEback to summary
public static final DBSCANClusterer.PointStatus NOISE

The point has is considered to be noise.

PART_OF_CLUSTERback to summary
public static final DBSCANClusterer.PointStatus PART_OF_CLUSTER

The point is already part of a cluster.

Constructor Detail

PointStatusback to summary
private PointStatus()

Method Detail

valueOfback to summary
public static DBSCANClusterer.PointStatus valueOf(String name)
valuesback to summary
public static DBSCANClusterer.PointStatus[] values()