Class DBScan<T>
- java.lang.Object
-
- smile.clustering.PartitionClustering<T>
-
- smile.clustering.DBScan<T>
-
- Type Parameters:
T- the type of input object.
- All Implemented Interfaces:
- java.io.Serializable, Clustering<T>
public class DBScan<T> extends PartitionClustering<T> implements java.io.Serializable
Density-Based Spatial Clustering of Applications with Noise. DBScan finds a number of clusters starting from the estimated density distribution of corresponding nodes.DBScan requires two parameters: radius (i.e. neighborhood radius) and the number of minimum points required to form a cluster (minPts). It starts with an arbitrary starting point that has not been visited. This point's neighborhood is retrieved, and if it contains sufficient number of points, a cluster is started. Otherwise, the point is labeled as noise. Note that this point might later be found in a sufficiently sized radius-environment of a different point and hence be made part of a cluster.
If a point is found to be part of a cluster, its neighborhood is also part of that cluster. Hence, all points that are found within the neighborhood are added, as is their own neighborhood. This process continues until the cluster is completely found. Then, a new unvisited point is retrieved and processed, leading to the discovery of a further cluster of noise.
DBScan visits each point of the database, possibly multiple times (e.g., as candidates to different clusters). For practical considerations, however, the time complexity is mostly governed by the number of nearest neighbor queries. DBScan executes exactly one such query for each point, and if an indexing structure is used that executes such a neighborhood query in O(log n), an overall runtime complexity of O(n log n) is obtained.
DBScan has many advantages such as
- DBScan does not need to know the number of clusters in the data a priori, as opposed to k-means.
- DBScan can find arbitrarily shaped clusters. It can even find clusters completely surrounded by (but not connected to) a different cluster. Due to the MinPts parameter, the so-called single-link effect (different clusters being connected by a thin line of points) is reduced.
- DBScan has a notion of noise. Outliers are labeled as Clustering.OUTLIER, which is Integer.MAX_VALUE.
- DBScan requires just two parameters and is mostly insensitive to the ordering of the points in the database. (Only points sitting on the edge of two different clusters might swap cluster membership if the ordering of the points is changed, and the cluster assignment is unique only up to isomorphism.)
- In high dimensional space, the data are sparse everywhere because of the curse of dimensionality. Therefore, DBScan doesn't work well on high-dimensional data in general.
- DBScan does not respond well to data sets with varying densities.
References
- Martin Ester, Hans-Peter Kriegel, Jorg Sander, Xiaowei Xu (1996-). A density-based algorithm for discovering clusters in large spatial databases with noise". KDD, 1996.
- Jorg Sander, Martin Ester, Hans-Peter Kriegel, Xiaowei Xu. (1998). Density-Based Clustering in Spatial Databases: The Algorithm GDBSCAN and Its Applications. 1998.
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface smile.clustering.Clustering
OUTLIER
-
-
Constructor Summary
Constructors Constructor and Description DBScan(T[] data, Distance<T> distance, int minPts, double radius)Constructor.DBScan(T[] data, Metric<T> distance, int minPts, double radius)Constructor.DBScan(T[] data, RNNSearch<T,T> nns, int minPts, double radius)Clustering the data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublegetMinPts()Returns the parameter of minimum number of neighbors.doublegetRadius()Returns the radius of neighborhood.intpredict(T x)Cluster a new instance.java.lang.StringtoString()-
Methods inherited from class smile.clustering.PartitionClustering
getClusterLabel, getClusterSize, getNumClusters, seed, seed
-
-
-
-
Constructor Detail
-
DBScan
public DBScan(T[] data, Distance<T> distance, int minPts, double radius)
Constructor. Clustering the data. Note that this one could be very slow because of brute force nearest neighbor search.- Parameters:
data- the dataset for clustering.distance- the distance measure for neighborhood search.minPts- the minimum number of neighbors for a core data point.radius- the neighborhood radius.
-
DBScan
public DBScan(T[] data, Metric<T> distance, int minPts, double radius)
Constructor. Clustering the data. Using cover tree for nearest neighbor search.- Parameters:
data- the dataset for clustering.distance- the distance measure for neighborhood search.minPts- the minimum number of neighbors for a core data point.radius- the neighborhood radius.
-
-
Method Detail
-
getMinPts
public double getMinPts()
Returns the parameter of minimum number of neighbors.
-
getRadius
public double getRadius()
Returns the radius of neighborhood.
-
predict
public int predict(T x)
Cluster a new instance.- Specified by:
predictin interfaceClustering<T>- Parameters:
x- a new instance.- Returns:
- the cluster label. Note that it may be
Clustering.OUTLIER.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG