{
  "id": "dbscan",
  "title": "DBSCAN",
  "lang": "en",
  "source_lang": "en",
  "summary": "DBSCAN is a density-based clustering algorithm that identifies dense, connected groups of observations and labels points outside those groups as noise.",
  "category": "computer-science",
  "subcategory": "artificial-intelligence",
  "type": "concept",
  "aliases": [
    "Density-Based Spatial Clustering of Applications with Noise"
  ],
  "generated_at": "2026-11-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/dbscan/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/dbscan/",
      "json": "https://aiwiki.page/zh/dbscan.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "DBSCAN (Density-Based Spatial Clustering of Applications with Noise) is an unsupervised learning algorithm that groups observations into clusters according to the density of their neighborhoods. It connects sufficiently dense regions, allowing clusters to have irregular shapes, and labels observations outside those regions as noise. Unlike methods that require a predetermined number of clusters, DBSCAN derives the number of clusters from the data and two density parameters: a neighborhood radius and a minimum neighborhood population."
    },
    {
      "heading": "Background and purpose",
      "text": "DBSCAN was introduced in 1996 by Martin Ester, Hans-Peter Kriegel, Jörg Sander, and Xiaowei Xu at the Second International Conference on Knowledge Discovery and Data Mining. It addressed a problem in spatial data mining: identifying clusters of arbitrary shape in large datasets containing noise.\n\nMany clustering methods characterize a group through a representative center or pairwise similarity. DBSCAN instead treats a cluster as a connected region of sufficiently high local density, separated from other clusters by regions of lower density. This makes it suitable for structures such as curved bands, elongated groups, and rings, provided their sampling density supports the chosen parameters.\n\nAlthough its name refers to spatial applications, DBSCAN is not restricted to geographic coordinates. It can operate on numerical feature vectors or on observations for which a suitable distance or dissimilarity is available."
    },
    {
      "heading": "Neighborhoods and point types",
      "text": "Let \\(D\\) be a finite dataset and \\(d(p,q)\\) a distance between observations \\(p\\) and \\(q\\). DBSCAN uses two hyperparameters:\n\n- Neighborhood radius, \\(\\varepsilon\\): the maximum distance at which two observations are considered neighbors.\n- Minimum number of points, \\(\\mathrm{MinPts}\\): the minimum neighborhood population required for an observation to qualify as a core point.\n\nThe closed neighborhood of \\(p\\) is\n\n\\[N_{\\varepsilon}(p)=\\{q\\in D:d(p,q)\\leq\\varepsilon\\}.\\]\n\nUnder the usual convention, the neighborhood includes \\(p\\) itself. Thus, with \\(\\mathrm{MinPts}=5\\), a point needs at least four other observations within the radius to qualify as a core point.\n\nDBSCAN distinguishes three kinds of observations:\n\n- A core point satisfies \\(|N_{\\varepsilon}(p)|\\geq\\mathrm{MinPts}\\).\n- A border point is not a core point but lies within the neighborhood of at least one core point.\n- A noise point is neither a core point nor a border point.\n\nThese categories depend on the distance, dataset, and parameter settings. “Noise” is an algorithmic label, not a finding that an observation is erroneous or unimportant.\n\nA border point belongs to a cluster but does not extend it. In particular, a chain made entirely of non-core points cannot connect two dense regions."
    },
    {
      "heading": "Density reachability and connectivity",
      "text": "DBSCAN formalizes its notion of a cluster using density-based relationships.\n\nA point \\(q\\) is directly density-reachable from \\(p\\) when \\(p\\) is a core point and \\(q\\in N_{\\varepsilon}(p)\\). This relationship need not be symmetric: a border point can be directly density-reachable from a core point without the reverse being true.\n\nA point \\(q\\) is density-reachable from \\(p\\) when there is a sequence\n\n\\[p=p_1,p_2,\\ldots,p_k=q\\]\n\nsuch that each \\(p_{i+1}\\) is directly density-reachable from \\(p_i\\). Every point that propagates the sequence must therefore be a core point, although its final point may be a border point.\n\nTwo points are density-connected if both are density-reachable from some common point. These definitions explain how a cluster can extend over a large distance even though each individual expansion uses only a local neighborhood.\n\nAn equivalent operational description is:\n\n- Identify all core points.\n- Connect pairs of core points whose distance is at most \\(\\varepsilon\\).\n- Find the connected components of this core-point graph.\n- Attach each non-core point to an adjacent component, if one exists.\n- Label all remaining points as noise.\n\nThe connected components of core points are unambiguous for fixed data and parameters. A border point, however, may lie within reach of core points from two otherwise separate components. Conventional DBSCAN assigns it to whichever cluster reaches it first. Its assignment can therefore depend on processing order without merging the two core components."
    },
    {
      "heading": "Algorithm",
      "text": "A standard implementation scans observations and expands a cluster whenever it encounters a previously unprocessed core point:\n\n- Select an unvisited observation \\(p\\) and mark it as visited.\n- Retrieve \\(N_{\\varepsilon}(p)\\).\n- If the neighborhood contains fewer than \\(\\mathrm{MinPts}\\) observations, provisionally mark \\(p\\) as noise.\n- Otherwise, create a cluster and place the neighborhood in an expansion worklist.\n- Process the worklist. For each unvisited point, retrieve its neighborhood; if that point is core, add its neighbors to the worklist.\n- Assign reached observations to the cluster when they are not already assigned to another cluster.\n- Continue until all observations have been visited.\n\nAn observation provisionally marked as noise can later become a border point when reached from a core point. Consequently, an implementation must not treat an early noise label as permanently excluding the observation from all clusters.\n\nCluster expansion can be implemented with a queue or another worklist, following a traversal similar to breadth-first search. The central computational operation is the radius-neighborhood query."
    },
    {
      "heading": "Distance and data representation",
      "text": "DBSCAN’s output depends on the meaning of distance in the chosen representation. Euclidean distance is common, but alternatives can be appropriate for geographic coordinates, binary attributes, or other data types. Some implementations accept a precomputed dissimilarity matrix.\n\nFeature scaling is important when numerical attributes have different units or ranges. For example, an unscaled distance combining age and annual income may be dominated by income. Rescaling changes neighborhoods and therefore changes the clustering.\n\nFor geographic coordinates, treating latitude and longitude as ordinary Cartesian coordinates can distort distance. A suitable projection or spherical distance can make the radius correspond more closely to the intended physical separation.\n\nDBSCAN can also be applied to features produced by representation learning. In that setting, the clusters reflect the geometry of the representation, which need not correspond directly to semantic categories."
    },
    {
      "heading": "Parameter selection",
      "text": "The two parameters jointly determine what constitutes a dense region.\n\nNeighborhood radius\n\nA small \\(\\varepsilon\\) produces small neighborhoods, potentially fragmenting groups or labeling many observations as noise. A large radius tends to connect more observations, potentially merging groups through dense bridges.\n\nA common heuristic examines a sorted \\(k\\)-distance plot: for every point, calculate its distance to a selected nearest neighbor and sort those distances. A marked bend may suggest a transition between dense regions and more isolated observations. The neighbor-counting convention must be consistent with whether the point itself is included in \\(\\mathrm{MinPts}\\).\n\nA clear bend is not guaranteed, especially when the dataset contains several density scales. The plot is a diagnostic aid rather than a universal parameter-selection rule.\n\nMinimum neighborhood population\n\nA larger \\(\\mathrm{MinPts}\\) requires stronger local support and can suppress small accidental groups. It can also prevent genuine small clusters from being recognized. A smaller value allows thinner or smaller structures but makes sparse connections more likely to join groups.\n\nThe often-cited rule of choosing \\(\\mathrm{MinPts}\\) greater than the number of dimensions is a heuristic, not a guarantee of useful clustering. Appropriate values depend on dimensionality, sample size, noise, and the intended scale of structure.\n\nUnlike k-means clustering, DBSCAN does not require the number of clusters as input. This does not eliminate model selection: different density parameters can yield substantially different numbers of clusters and noise fractions."
    },
    {
      "heading": "Computational cost",
      "text": "DBSCAN’s time complexity depends mainly on neighborhood search. For \\(n\\) observations, directly comparing every observation with every other observation requires \\(O(n^2)\\) distance evaluations.\n\nA spatial index such as a k-d tree can accelerate queries when dimensionality, geometry, and neighborhood sizes are favorable. Under suitable conditions, implementations can achieve approximately \\(O(n\\log n)\\) total time. This is not a general guarantee: large neighborhoods, high dimensionality, or an unsuitable distance can lead to quadratic behavior.\n\nMemory requirements are also implementation-dependent:\n\n- An on-demand implementation can use \\(O(n)\\) auxiliary memory beyond the dataset and search index.\n- An implementation that stores all neighborhoods requires memory proportional to the total number of neighbor relationships, which can reach \\(O(n^2)\\).\n- A dense precomputed distance matrix itself requires \\(O(n^2)\\) storage.\n\nParallel and distributed implementations can accelerate parts of the computation, but must reconcile core-point connectivity across processing partitions."
    },
    {
      "heading": "Strengths and limitations",
      "text": "Irregular shapes and explicit noise\n\nDBSCAN can identify non-convex groups without representing them by a centroid. It also distinguishes unassigned observations from cluster members, rather than forcing every observation into a cluster.\n\nThese properties do not mean that it can recover every visually apparent shape. A structure must have enough local support to form a connected core, and dense bridges can merge groups that appear conceptually distinct.\n\nVarying density\n\nA single global radius and minimum population are often inadequate when clusters have substantially different densities. A radius small enough to preserve a dense cluster may fragment a sparse one; a radius large enough to recover the sparse cluster may merge dense groups.\n\nHigh dimensionality\n\nThe curse of dimensionality can weaken the usefulness of distance and reduce the efficiency of spatial indexes. In many high-dimensional datasets, distances become less discriminating, making one meaningful neighborhood radius difficult to select.\n\nDimensionality reduction can change this behavior, but also changes the neighborhood structure. Clusters found after projection are clusters in the transformed space.\n\nOrder dependence and interpretation\n\nFor fixed distances and parameters, core status, core components, and the final noise set do not depend on traversal order. Ambiguous border assignments can depend on it, and numeric cluster labels can be permuted without changing the grouping.\n\nDBSCAN does not establish that its clusters correspond to natural categories or causal processes. Density patterns can reflect sampling practices, duplicated records, measurement procedures, or the selected features. Assessing results therefore requires attention to both the algorithm and data quality."
    },
    {
      "heading": "Applications and related methods",
      "text": "DBSCAN is used in spatial pattern discovery, point-cloud processing, trajectory analysis, and exploratory grouping. In computer vision, it can group nearby points or detections. In anomaly detection, its noise label can identify observations outside dense groups, although sparse observations are not necessarily anomalous and anomalies can themselves form dense clusters.\n\nSeveral methods address related problems:\n\n- OPTICS produces an ordering and reachability information that expose density-based structure across a range of neighborhood scales.\n- HDBSCAN constructs a density-based hierarchy and selects clusters using stability-related criteria, helping accommodate groups with different densities.\n- DBSCAN* excludes border points from clusters, retaining only core components and thereby avoiding ambiguous border assignments.\n\nK-means remains a contrasting approach: it typically assigns every observation to one of a specified number of centroid-based groups. DBSCAN instead emphasizes local density, connectivity, and the possibility that some observations belong to no cluster."
    }
  ],
  "links": [
    "unsupervised-learning",
    "algorithm",
    "data-mining",
    "hyperparameter",
    "queue-data-type",
    "breadth-first-search",
    "feature-scaling",
    "representation-learning",
    "heuristic",
    "k-means-clustering",
    "time-complexity",
    "kd-tree",
    "parallel-computing",
    "distributed-computing",
    "curse-of-dimensionality",
    "data-quality",
    "computer-vision",
    "anomaly-detection"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}