Skip to main content

Fuzzy Neighborhood DBSCAN clustering algorithm

Project description

FN-DBSCAN: Fuzzy Neighborhood DBSCAN

Python Version License: MIT

Implementation of Fuzzy Neighborhood DBSCAN (FN-DBSCAN), a density-based clustering algorithm that extends classic DBSCAN using fuzzy theory.

Installation

git clone https://github.com/onurceldir123/fn-dbscan.git
cd fn-dbscan
pip install -e .

Requirements: Python ≥3.8, NumPy, scikit-learn, scipy

Quick Start

from sklearn.datasets import make_moons
from fn_dbscan import FN_DBSCAN

X, _ = make_moons(n_samples=200, noise=0.05, random_state=42)

model = FN_DBSCAN(
    eps=0.1,                  
    min_fuzzy_neighbors=5.0,    
    min_membership=0.0,        
    fuzzy_function='exponential', 
    normalize=True              
)

labels = model.fit_predict(X)

print(f"Found {model.n_clusters_} clusters")

Why FN-DBSCAN?

While classic DBSCAN is powerful, it relies on a "crisp" boundary—a point is either a neighbor or it isn't. FN-DBSCAN improves upon this by introducing fuzzy set theory:

  • [cite_start]Robustness to Density Variations: It is more robust than DBSCAN when handling datasets with varying densities and shapes[cite: 19, 61].
  • Soft Boundaries: Instead of an all-or-nothing approach, it calculates a "fuzzy cardinality" (sum of membership degrees). [cite_start]This handles border points and noise more naturally [cite: 153-155].
  • [cite_start]Scale Invariance: The implementation includes the normalization technique proposed in the paper, making the eps parameter adaptable to the data scale [cite: 127-141].
  • [cite_start]Best of Both Worlds: Combines the speed of DBSCAN with the robustness of fuzzy clustering methods like NRFJP[cite: 18, 60].

Parameters

Core Parameters

Parameter Type Default Description
eps float 0.5 Maximum neighborhood radius (0-1 for normalized data).
min_fuzzy_neighbors float 5.0 Minimum fuzzy cardinality to be a core point (analogous to min_samples in DBSCAN).
min_membership float 0.0 Minimum membership threshold ($\epsilon_1$). Points with membership below this are ignored.
fuzzy_function str 'linear' Membership function: 'linear', 'exponential', or 'trapezoidal'.
normalize bool True Normalize data to make eps scale-independent (Strongly Recommended).
k float None Steepness parameter. Controls how fast membership drops. Higher $k$ = stricter neighborhood. Auto-calculated as $d_{max}/\epsilon$ if None.
metric str 'euclidean' Distance metric (any scikit-learn compatible metric).

Fuzzy Functions

  • 'exponential' - Recommended for most cases, especially non-convex clusters
  • 'linear' - Simple linear decay, good for well-separated clusters
  • 'trapezoidal' - Maintains full membership for very close points

Model Attributes

After fitting, the model provides:

  • labels_ - Cluster labels for each sample (-1 for noise)
  • core_sample_indices_ - Indices of core points
  • n_clusters_ - Number of clusters found

Algorithm Overview

FN-DBSCAN extends DBSCAN by computing fuzzy cardinality instead of discrete point counts:

Traditional DBSCAN:  cardinality = count(neighbors)
FN-DBSCAN:          cardinality = Σ membership(distance(p, q))

A point is a core point if its fuzzy cardinality ≥ min_fuzzy_neighbors.

Citation

If you use FN-DBSCAN in your research, please cite the original paper:

@article{nasibov2009robustness,
  title={Robustness of density-based clustering methods with various neighborhood relations},
  author={Nasibov, Efendi N and Ulutagay, G{\"o}zde},
  journal={Fuzzy Sets and Systems},
  volume={160},
  number={24},
  pages={3601--3615},
  year={2009},
  publisher={Elsevier}
}

License

MIT License - see LICENSE file for details.

Contributing

Contributions welcome! Please open an issue or submit a pull request on GitHub.


Reference: Nasibov, E. N., & Ulutagay, G. (2009). Robustness of density-based clustering methods with various neighborhood relations. Fuzzy Sets and Systems, 160(24), 3601-3615.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fn_dbscan-0.1.0.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fn_dbscan-0.1.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file fn_dbscan-0.1.0.tar.gz.

File metadata

  • Download URL: fn_dbscan-0.1.0.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for fn_dbscan-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3cbe4144ceff85841b71b310fa76d294541772fd6775cadfa5362a4b22c0d173
MD5 5e9d2dab70212be5f3cbfd7e4d887d56
BLAKE2b-256 24a59027b215236593313d1443b9ee4a6957049dd4ae005595bc90e3056336ee

See more details on using hashes here.

File details

Details for the file fn_dbscan-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fn_dbscan-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for fn_dbscan-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3943678c8a3bf01af224f867c27d9e48b2645fe82c9ac60625037f806342a454
MD5 157dfb77df22248e7010f828c23a7b9f
BLAKE2b-256 1bca89320710ace60b0d5581b814947ccfd2ebb16392876a6bb3b183c08b6d35

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page