This repository provides a Jupyter Notebook for interactive visualization and animation of the DBSCAN (Density-Based Spatial Clustering of Applications with Noise) algorithm. The notebook illustrates the algorithm step by step, including:
- Core point detection
- Connecting core points
- Formation of clusters
With ipywidgets interactive controls, users can adjust algorithm parameters in real time—such as the number of sample points, neighborhood radius, and minimum points—and immediately see how these changes affect the clustering results through dynamic animations.
Click the button below to view the animation:
This project can be run entirely in your browser — no local installation required — and offers two options for online execution: Binder for interactive, code-free visualization, and Google Colab for full notebook editing and experimentation.
For viewers who just want to see and interact with the animations without seeing code or Markdown:
Beyond the Voila-rendered version,there is a fully interactive notebook environment available.
Click here to view, run, and edit all code and Markdown cells within a temporary, interactive environment:
The Google Colab version provides a full-featured online Notebook environment.
You can run and modify code directly in your browser, and save any changes to your Google Drive:
To run this project locally, make sure your environment has the following Python packages installed (see requirements.txt for specific versions):
numpymatplotlibnetworkxshapelyipywidgets
Click to view installation steps
-
Create a virtual environment (optional but recommended):
python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Edit the notebook: Open
dbscan_animator.ipynbin thesrcdirectory and run the cells in order. Adjust parameters via the control panel, then clickRun Interactto start the animation. -
Display with Voila locally: The source notebook contains Markdown cells and outputs that may affect its appearance when served with Voila. It is recommended to create a cleaned copy with Markdown cells removed and outputs cleared beforing serving it with Voila:
jq '(.cells |= map(select(.cell_type != "markdown") | .outputs = [] | .execution_count = null))' \
src/dbscan_animator.ipynb > build/dbscan_animator_for_display.ipynbThen run:
voila build/dbscan_animator_for_display.ipynbOpen http://localhost:8866 to view the demo.
- Core DBSCAN Functions: Implements main DBSCAN logic with
find_core_points,build_core_graph, andfind_reachable_and_noise. - Visualization Tools: Functions for plotting points, core circles, connections, and cluster polygons.
- Animations:
radar_animationfor neighborhood scanning andcore_connection_animationto visualize cluster connections. - Workflow:
dbscan_workflowhandles the UI and coordinates the step-by-step animation.
Feel free to open Issues or Pull Requests! Please follow the repository's license and contribution guidelines.
MIT License — see the LICENSE file for details.