Skip to content

gagolews/deadwood

Repository files navigation

deadwood Package for R and Python

Deadwood: Outlier Detection via Pruning Mutual Reachability Minimum Spanning Trees

deadwood for Python deadwood for R

Keywords: Deadwood, outlier detection, anomaly detection, HDBSCAN*, DBSCAN, minimum spanning tree, MST, density estimation, mutual reachability distance.

Refer to the package homepage at https://deadwood.gagolewski.com/ for the reference manual, tutorials, examples, and benchmarks.

Author and Maintainer: Marek Gagolewski

About

Deadwood is an anomaly detection algorithm based on a dataset's mutual reachability minimum spanning tree. It chops protruding tree segments and marks small debris as outliers.

More precisely:

  • the use of a mutual reachability distance pulls peripheral points farther away from each other,

  • tree edges with weights beyond the detected elbow point are removed,

  • all the resulting connected components whose sizes are smaller than a given threshold are deemed anomalous.

How to Install

Python Version

To install from PyPI, call:

pip3 install deadwood  # python3 -m pip install deadwood

To learn more about Python, check out my open-access textbook Minimalist Data Wrangling in Python.

R Version

To install from CRAN, call:

install.packages("deadwood")

To learn more about R, check out my open-access textbook Deep R Programming.

Other

The core functionality is implemented in the form of a C++ library. It can thus be easily adapted for use in other projects.

New contributions are welcome, e.g., Julia, Matlab/GNU Octave wrappers.

License

Copyright (C) 2025–2026 Marek Gagolewski https://www.gagolewski.com/

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License Version 3, 19 November 2007, published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License Version 3 for more details. You should have received a copy of the License along with this program. If not, see (https://www.gnu.org/licenses/).

References

TODO

See deadwood's homepage for more references.