EZ LearnEZ Learn
Courses
EZ Board
Dashboard
All articles
ml-for-cyber-securitymlcsdbscanclustering

DBSCAN: Clusters Without Choosing k

DBSCAN needs no k, finds clusters k-means' circular boundaries cannot represent, and, most usefully for security work, explicitly labels sparse points as noise rather than forcing them into the nearest cluster.

Ashish Revar25 October 20265 min read

DBSCAN (Density-Based Spatial Clustering of Applications with Noise) takes a different approach: a cluster is any region where points are densely packed together, separated by sparser regions. It needs no $k$, discovers arbitrarily shaped clusters that k-means' circular boundaries cannot represent, and, most usefully for security work, explicitly labels sparse, isolated points as noise rather than forcing them into the nearest cluster.

dbscan_network_flows.py

from sklearn.cluster import DBSCAN

dbscan = DBSCAN(eps=0.6, min_samples=8)
labels = dbscan.fit_predict(scaled)
n_outliers = (labels == -1).sum()
print(f"DBSCAN found {labels.max() + 1} clusters and {n_outliers} outliers")

Tool in focus: sklearn.cluster.DBSCAN

The two parameters that matter are eps (how close two points must be to count as neighbours) and min_samples (how many neighbours a point needs to anchor a dense region). Points that join no dense region at all are labelled -1: DBSCAN's built-in outlier flag, exactly the flag a security analyst wants.

Try it yourself: k-Means or DBSCAN?

A dataset's normal traffic forms one large, roughly circular cluster and one small, crescent-shaped cluster that wraps partway around it, with a handful of genuinely isolated points scattered far from both. Which algorithm from this unit would correctly separate the crescent from the circle without being told how many clusters to expect, and would also correctly flag the isolated points as outliers instead of forcing them into the nearest cluster?

Related to this topic

Continue learning

Reference material

eBook

ML for Cyber Security eBook

v1.0

Open resource

Cheatsheet

ML for Cyber Security Cheatsheet

v1.0

Open resource

MCQ Bank

ML for Cyber Security MCQ Bank

v1.0

Open resource

Question Bank

ML for Cyber Security Question Bank

v1.0

Open resource

Discussion

Loading comments…
More articlesTest your knowledge
EZ MentorAI · Free

DBSCAN: Clusters Without Choosing k

Hi! I'm EZ Mentor

Your AI tutor for
DBSCAN: Clusters Without Choosing k

Sign in to ask, it's free.

EZ Mentor is AI-powered · Answers may not be perfect · 10 free questions / day

EZ Learn

Structured learning across Reverse Engineering, Cloud Security and Research Methodology, plus games and practice tools. Free, and open to anyone.

Learn

  • Courses
  • EZ Articles
  • EZ Watch
  • EZ Bytes
  • EZ Talks
  • Community

Library & Exams

  • All Resources
  • eBooks & PDFs
  • Question Banks
  • Cheatsheets
  • All Exams
  • EZ Board

EZ Arena

  • EZ Games
  • Byte Rush
  • Firewall Defence
  • 3D Case Files
  • Live Quiz
  • ML Challenges

EZ Cyber Hygiene

  • Hygiene Journey
  • Cyber Safety Check
  • दिशा - Hygiene
  • सजग - Awareness
  • अभ्यास - Practice
  • Scammed? Call 1930

Platform

  • About
  • Contact
  • Events
  • Verify Certificate
  • Terms of Use
  • Disclaimer

© 2026 EZ Learn by EpochZero. Educational content for learning purposes.

Platform Lead: Ashish Revar