DBSOD: Density-Based Spatial Outlier Detection
Official implementation of "DBSOD: Density-Based Spatial Outlier Detection". Paper preprint is coming soon.
Algorithm
While DBSCAN is a widely used clustering algorithm, it only provides a binary label for outliers and does not assign a continuous outlierness score. To address this limitation, we propose DBSOD, a density-based spatial outlier detection method inspired by DBSCAN. The algorithm estimates the consistency with which a data point is identified as an outlier across a range of neighborhood sizes:
The algorithm systematically varies the neighborhood size parameter $\epsilon$, evaluating outlierness across multiple density assumptions. By aggregating binary outlier classifications across these scales, it produces a normalized outlierness score for each point, reflecting how consistently the point is identified as an outlier.
It is also possible to estimate outlierness score for unseen data (novelty detection). Here, each new data point is treated as a non-core candidate for expansion of a cluster obtained from training data. The algorithm then estimates the consistency with which a data point does not expand the cluster.
Installation
Note: the package was developed for Linux (manylinux, x86_64) machines.
You can install package using pip:
pip install dbsod
Alternatively (for instance if you want to contribute) you may clone this repository, build dbsod and install it in .venv in editable mode:
git clone https://github.com/Kowd-PauUh/dbsod.git
cd dbsod
make install_g++
make venv
Usage
Take as an example this dataset:
import numpy as np
DATA = np.array([
[0.35, 0.18],
[0.60, 0.16],
[0.40, 0.18],
[0.40, 0.30],
[0.30, 0.70],
])
We can use DBSOD to calculate outlierness score for each point:
from dbsod import dbsod, DBSOD
EPS_SPACE = [0.15, 0.22] # `eps` parameters used for calculating normalized outlierness score
MIN_PTS = 2 # minimum number of neighbors for the data point to become "core" point
# Initialize model
model = DBSOD(
eps_space=EPS_SPACE,
min_pts=MIN_PTS,
)
# Fit model and get outlierness scores of the training data points
# This can be also achieved using:
# `model.fit_predict(X=DATA)` or `dbsod(X=DATA, eps_space=EPS_SPACE, min_pts=MIN_PTS)`
outlierness_scores = model.fit(X=DATA).outlierness_score
print(outlierness_scores)
The output will be: array([0. , 0.5, 0. , 0. , 1. ]).
Below is the visualization of this example:
Having fitted the DBSOD, we can estimate outlierness scores for the new data points:
# prepare a 3x3 grid of points
x, y = np.meshgrid(np.linspace(0.2, 0.5, 3), np.linspace(0.2, 0.5, 3))
points = np.column_stack([x.ravel(), y.ravel()])
# estimate outlierness score for each new point
predictions = model.predict(points)
print(predictions)
The output of this is: array([0.5, 0. , 0. , 0.5, 0. , 0. , 1. , 0.5, 1. ]).
Notice how we can use DBSOD to estimate outlierness of the points in a grid with an arbitrary resolution. This effectively allows us to create outlierness heatmaps.
On the real-world data (check out this and this examples) result of applying DBSOD would look like this:
Time and space complexity
| Method | Time complexity (worst case) | Space complexity (worst case) |
|---|---|---|
.fit |
$O(N^2 \cdot (d + logN))$ | $O(N^2)$ |
.predict |
$O(N \cdot M \cdot d)$ | $O(N + M)$ |
Given that len(eps_space) $\ll N$, where:
$N$ – number of points used to fit the algorithm;
$M$ – number of points used to predict scores for;
$d$ – point dimensionality.
Citation
@software{danylenko2025dbsod,
author = {Danylenko, Ivan},
doi = {10.5281/zenodo.19557644},
month = apr,
title = {{DBSOD: Density-Based Spatial Outlier Detection}},
url = {https://github.com/Kowd-PauUh/dbsod},
version = {0.1.0},
year = {2026}
}
Metadata
Release files for dbsod 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 11.2 MB
Release files / dbsod-0.2.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | dbsod-0.2.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
d2b8604ac808a7f8939ad3ef507119477bc85fcc88b4b6cd2ab394453169528a
|
|
BLAKE2b-256 checksum How to use checksums |
d966c24ed7d630dcc08e47c5cd8bab37fc083b79e915a62e3d53297bc106efa6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 4, 2026.
Transparency logRelease files / dbsod-0.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | dbsod-0.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
86da7e175e682e3d0b1bf53d54736175eb7ae1da88f731548c608fec7a4ff945
|
|
BLAKE2b-256 checksum How to use checksums |
c0762f88c84f84e13263098aa0c5868b5774052b4688347fe9ceb95e2448255d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 4, 2026.
Transparency logRelease files / dbsod-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | dbsod-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
b38fb3eb7418bc844008b7e69f26cca1061275f7ceea77421d65dd1c1e42393d
|
|
BLAKE2b-256 checksum How to use checksums |
38894403270dc75dfd95e1aefcced2d84f6f21de1f0c20902054cdf6e44d8a97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 4, 2026.
Transparency logRelease files / dbsod-0.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | dbsod-0.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
2755e97f6312d0b54691aba33197bb1254f4a3903f96b154821589ce0a2228c9
|
|
BLAKE2b-256 checksum How to use checksums |
28834a8c4f1c0da4306770bc0079376faf97bcd9dc7fea38dc91d415979c8889
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 4, 2026.
Transparency logRelease files / dbsod-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | dbsod-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
d0388888dcc1af7d4343bbdf26657fc7ebee3176975432fa251b1d36c8283e08
|
|
BLAKE2b-256 checksum How to use checksums |
04283fa74f1f7b76fc232b146a8380a5e7418641c117aa91feafea48c2342dd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 4, 2026.
Transparency logRelease files / dbsod-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | dbsod-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
9f4659233be0038174de535f4cecc96599f7ea6e956c0fe9d658b68548fb2325
|
|
BLAKE2b-256 checksum How to use checksums |
64184926e43e567c67925621c66f7d4989cb98ea9b81dca528d0752c7262642d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 4, 2026.
Transparency logSecurity for dbsod 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for dbsod-0.2.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.