Clustering, density estimation, and anomaly detection · Density and exemplar clustering · UCL021 · Algorithm
DBSCAN
Discover density-connected groups while marking unsupported observations as noise. It can recover curved clusters and avoids requiring a prespecified cluster count.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page.
- DBSCAN Verified in Python and R
Do it in CodeSplash Run it on your own data, in Python or R.
- Availability
- Runs in CodeSplash
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- Verified in Python and R through discover.dbscan. The reference's example ran here in one language.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Discover density-connected groups while marking unsupported observations as noise. It can recover curved clusters and avoids requiring a prespecified cluster count.
Question / hypotheses
Which dense groups, modes, or exemplars persist under a defensible similarity scale? This entry defines an estimation or optimization objective, not an intrinsic null/alternative hypothesis test.
Architecture / computational structure
Radius-neighbor queries classify core points; density reachability joins components and border cases.
Assumptions
A single radius assumes a useful common density scale; it struggles when meaningful groups differ greatly in density. Border assignments may depend on traversal order. In high dimensions, distances can concentrate, and a large radius can require near-quadratic memory.
Formula / computational definition
The radius neighborhood is . A core point has at least min_samples neighbors under the implementation's counting convention. Clusters are connected components of density reachability from core points, augmented by reachable border points.
Parameters and notation
Learned or fitted quantities: Core/border/noise status and cluster labels. User-set hyperparameters/design choices: Choose radius , minimum count, distance, and scaling. Tune these against the stated objective and stability/validation criteria; do not select settings on the final evaluation set.
Fitting, fine-tuning, and adaptation
Neural fine-tuning is not applicable. Refit or rebuild neighborhoods when the reference distribution changes. Recalibrate neighborhood and extraction settings using stable density structure; verify whether the implementation supports genuine new-point assignment before deployment.
How to use and calibrate
Report cluster count, noise fraction, core/border proportions, and sensitivity to radius. Silhouette on non-noise cases alone can look good after discarding difficult observations; disclose that filtering. A noise flag is not proof of a measurement error.
Example application
Identify dense spatial groupings while retaining an explicit noise category. Define the reference population, measurement units, and success criterion before fitting; investigate whether discovered groups or alerts reflect the intended phenomenon.
Interpretation / pitfalls
Watch out
The reported result is conditional on the representation and objective. A stable partition can reflect nuisance structure such as batch, collection site, or missingness. Confirm the interpretation in original variables and an independent sample.
Python and R code examples
Use sklearn.cluster.DBSCAN and dbscan::dbscan. Check self-neighbor and boundary conventions before matching outputs. Fit preprocessing on the intended reference population; feature scaling changes the density definition.
Component: DBSCAN core-point predicate including the point itself. Python: executed successfully; R: not executed (Rscript unavailable). These small fixtures establish the arithmetic operation, not full-method accuracy or reproduction of paper results.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — DBSCAN core-point predicate including the point itself. · needs numpy
import numpy as np
x=np.array([0.,.1,.2,2.]); eps=.15; min_samples=2
counts=(np.abs(x[:,None]-x)<=eps).sum(1)
result=counts>=min_samples
print(result)
Component demo, not a trained model — DBSCAN core-point predicate including the point itself.
x=c(0,.1,.2,2); eps=.15; min_samples=2
counts=rowSums(abs(outer(x,x,'-'))<=eps); result=counts>=min_samples
print(result)
Sources
- Source 1scikit-learn.org
- Source 2cran.r-project.org
From the CodeSplash reference, entry UCL021.