../ Data Science
-rw-r--r--aguang2.8 KiB3 min read

Density-based Spatial Clustering of Applications with Noise.

Density-based spatial clustering of applications with noise (DBSCAN) is a clustering algorithm.

Key Concepts

Let's say XX is the sef of all data points, dist(x,y)∈Rdist(x, y) \in R is a function to measure the distance between any two data points, ϵ∈R+\epsilon \in R^+ is the distance limitation and minPts∈Z+minPts \in Z^+ is the density limitation.

  • Given ϵ∈R+\epsilon \in R^+ and p∈Xp \in X, the ϵ\epsilon neighbors of pp is Nϵ(x)={y∈X∣dist(x,y)≤ϵ}N_{\epsilon}(x) = \{ y \in X \mid dist(x, y) \leq \epsilon \}.
  • Given x∈Xx \in X, the density of xx is ρ(x)=∣Nϵ(x)∣\rho(x) = \lvert N_{\epsilon}(x) \rvert .
  • Given x,y∈Xx, y \in X, if y∈Nϵ(x)y \in N_{\epsilon}(x) and ρ(x)≥minPts\rho(x) \geq minPts, then we say yy is directly density-reachable from xx.
  • Given x,y∈Xx, y \in X, if there is a sequence p1,p2,⋯ ,pnp_1,p_2,\cdots,p_n, where x=p1x = p_1, y=pny = p_n, and every pi+1p_{i + 1} is directly density-reachable from pip_i, then we say yy is density-reachable from xx.
  • Given x,y∈Xx, y \in X, if there is a data point o∈Xo \in X, where both xx and yy are density-reachable from oo, then we say xx and yy are density-connected.

The data points XX will be divided by DBSCAN into several clusters (containing core points and density-reachable points) based on density-connectivity and outliers.

  • Given ϵ∈R+\epsilon \in R^+, minPts∈Z+minPts \in Z^+ and x∈Xx \in X, if ρ(x)≥minPts\rho(x) \geq minPts then we say xx is a core point.
  • Given x∈Xx \in X, if xx is not a core point but is density-reachable from any core points, then we say xx is a density-reachable point.
  • Any other data points in XX are outliers.

Pseudo Code

DBSCAN(X,minPts,ϵ):Clusters←∅for x∈X:if x∉∪c∈Clustersc∧Nϵ(x)≥minPts:Clusters←Clusters∪Expand(X,x,minPts,ϵ)Outliers←X−∪c∈Clusterscreturn Clusters,Outliers\begin{aligned} & DBSCAN(X, minPts, \epsilon) :\\ & \quad Clusters \leftarrow \empty \\ & \quad \mathtt{for}\ x \in X: \\ & \quad \quad \mathtt{if}\ x \not \in \cup_{c \in Clusters} c \land N_{\epsilon}(x) \geq minPts :\\ & \quad \quad \quad \quad Clusters \leftarrow Clusters \cup Expand(X, x, minPts, \epsilon) \\ & \quad Outliers \leftarrow X - \cup_{c \in Clusters} c \\ & \quad \mathtt{return}\ Clusters, Outliers \\ \end{aligned} Expand(X,x,minPts,ϵ):Cluster←{x}for y∈Nϵ(x):if ∣Nϵ(y)∣≥minPts:Cluster←Cluster∪Expand(X,y,minPts,ϵ)else:Cluster←Cluster∪{y}return Cluster\begin{aligned} & Expand(X, x, minPts, \epsilon) :\\ & \quad Cluster \leftarrow \{ x \} \\ & \quad \mathtt{for}\ y \in N_{\epsilon}(x) :\\ & \quad \quad \mathtt{if}\ \lvert N_{\epsilon}(y) \rvert \geq minPts:\\ & \quad \quad \quad Cluster \leftarrow Cluster \cup Expand(X, y, minPts, \epsilon) \\ & \quad \quad \mathtt{else} :\\ & \quad \quad \quad Cluster \leftarrow Cluster \cup \{ y \} \\ & \quad \mathtt{return}\ Cluster \end{aligned}

References

COMMAND INTERFACE

↑ ↓ navigate · Enter execute · Esc exit · try “whoami”

Loading filesystem…

:help aguang.xyz

A personal website disguised as an operating system.

Ctrl / Cmd + K
Command palette + full-text search
Tab / Shift + Tab
Move between links and controls
Enter
Open a focused link or search result
↑ / ↓ in search
Navigate search results
In a directory filter
Enter/Done or ↓ focuses a result; Esc clears the filter
Esc
Clear a search or close a window